#💻┃code-beginner

1 messages · Page 782 of 1

radiant voidBOT
#

success @aspvect1 muted

Reason: if you want to continue posting here you will need to be less antagonistic. Follow basic posting etiquette, don't cross-post, and re-read our conduct if you have trouble.
Duration: 23 hours, 59 minutes and 59 seconds

safe temple
empty orchid
#

how would i get LookAt() to have a -90 offset on whatever the target is?

timber tide
eternal needle
#

i wouldnt be too concerned about errors like that. its more of just a showcase of how you can use it. Seems like they probably copied the code, initially writing it as a method with no params and just forgot to update that part. the PongRpc looks correct

naive pawn
#

a -90 degree offset? looking at a point -90 units offset?

weary depot
#

this is the best thing ive seen all day

celest mesa
#

Hi i need help with unity scripting I have it all installed with visual studio but when i look for create C# script it dosent show can someone help me with this?

wintry quarry
celest mesa
#

Im trying to find the stuff i learned in school but everything is just not there

celest mesa
#

and the loadscene prompt on click is it named something else?

#

is there an issue why the Scenemanager is not green?

slender nymph
#

!ide 👇

radiant voidBOT
celest mesa
slender nymph
#

follow the relevant guide and find out

celest mesa
#

Then what?

frosty hound
#

Then profit

celest mesa
#

ok thats cool

#

my visual studios doesn't open now

verbal dome
prime goblet
worthy veldt
#

I'm searching about setting predetermined value on a field in parent from child (scriptable object), and i cannot remember one of the method the AI suggests.
what i get is, either, well assign it normally in child or using the Reset() method

however there is something in my first search that i cannot remember the exact syntax, and i cant get the same result on google AI

public class ChildClassSO : ParentClassSO
{
    (?)private void ParentClassSO
  {
    parentField1 = ...
    parentField2 = ...
  } 
}

it is assigning from inside a method, i closed that google search tab, what is it about ?

wintry quarry
#

At what point in the lifecycle of the object do you want to set the values?

#

And are you sure you want to be setting fields? Why fields if you're going to set them to "predetermined" values?

rough granite
keen knot
#

Hello! Is it possible to play a video backwards using Video Player? I tried but it seems that it only goes forward

verbal dome
keen knot
verbal dome
#

Yeah, doc says

Support for negative values is platform dependent.

keen knot
verbal dome
#

No idea

#

But yeah I'd assume that if it's limited on some platforms then it would be mobile

#

Seems like you'd need to manually adjust the frame

keen knot
keen knot
# verbal dome Seems like you'd need to manually adjust the ``frame``

it works, but it has different speed from normal playback

void Update()
{
    if (reverse)
    {
        accumulator += Time.deltaTime;
        if (accumulator >= 1f / frameRate)
        {
            videoPlayer.frame--;
            Debug.Log("frame change");
            accumulator = 0;
            if (videoPlayer.frame <= 0)
            {
                reverse = false;
                videoPlayer.Play();
            }
        }
    }
    else if (videoPlayer.frame >= (long) clip.frameCount - 1)
    {
        reverse = true;
    }
}

verbal dome
#

Currently you are only advancing max 1 video frame per Update

#

A while loop allows it to catch up if it should play multiple video frames during this Update

keen knot
verbal dome
#

I don't see anything else setting reverse to false here

keen knot
naive pawn
#

can you show the current code

keen knot
#
[SerializeField] private VideoPlayer videoPlayer;
[SerializeField] private VideoClip clip;
[SerializeField] private float frameRate = 64f;
private bool reverse = false;
private float accumulator;
private void Start()
{
    videoPlayer.clip = clip;
    videoPlayer.Play();
}

void Update()
{
    if (reverse)
    {
        accumulator += Time.deltaTime;
        while (accumulator >= 1f / frameRate)
        {
            videoPlayer.frame--;
            Debug.Log("frame change");
            accumulator -= 1f / frameRate;
            if (videoPlayer.frame <= 0)
            {
                reverse = false;
                videoPlayer.Play();
            }
        }
    }
    else if (videoPlayer.frame >= (long) clip.frameCount - 1)
    {
        reverse = true;
    }
}
naive pawn
#

i don't see anything that would cause that, but i do notice that if you have a long frame when near 0 it'll keep going to negative frames

verbal dome
#

I haven't used video player but that might be causing an issue

#

Do you need audio?

#

Maybe try doing both forward and reverse playback by setting the frame

keen knot
verbal dome
#

So there's more code

keen knot
verbal dome
#

Might wanna add a break here

            if (videoPlayer.frame <= 0)
            {
                reverse = false;
                videoPlayer.Play();
                break;
            }```
So it stops without going to the negatives
#

Stops reversing, i mean

keen knot
#

It is getting stopped at some point (video length is 5 seconds).

verbal dome
#

Do you have VideoPlayer.isLooping enabled or no?

keen knot
verbal dome
#

Try enabling it

#

Maybe it thinks it's reaching the end and therefore stops it

keen knot
#

I enabled loop and skip on drop and it's working

#

But it's slower than playing in forward

#

Without Skip on drop it just loops

verbal dome
#

I don't see you stopping it anywhere

#

If it plays forward while you manually adjust the frames backwards then I wouldn't expect it to have the correct speed

keen knot
verbal dome
#

Just try calling Pause when you set reverse to true

#

Another thing to try is to convert your code from using frame to directly modifying time

#

So pretty much videoPlayer.time -= deltaTime instead of the delta accumulation etc.

keen knot
keen knot
verbal dome
keen knot
# verbal dome Show what you tried

private void Start()
{
    videoPlayer.clip = clip;
    videoPlayer.Play();
    videoPlayer.loopPointReached += EndLoop;
}
void EndLoop(VideoPlayer vp)
{
    reverse = true;
    videoPlayer.Pause();
}
void Update()
{
    if (reverse)
    {
        videoPlayer.time -= Time.deltaTime;
        if (videoPlayer.time <= 0)
        {
            reverse = false;
            videoPlayer.Play();
        }
    }

}
keen knot
verbal dome
#

Actually yeah I just took a closer look at the time docs and I don't think it's meant to be used for this

#

The only hack I can think of right now is to control both forward and reversed playback manually with frame (and with playback paused)

#

No idea why it wouldn't be the correct speed tho

#

The logic looked fine

worthy veldt
# wintry quarry At what point in the lifecycle of the object do you want to set the values?

the context is furniture in 2D game that player can place, i want to add decoration which do not have all 4 facing direction unlike furniture, but i don't want to copy paste same data for all 4, so I'm wondering can i make a child and fill just one data and automatically it will assign it to all 4 direction data of parent ?

I got it now that you need extra editor script to add button to run the method (the snippet) that will update the parent data during editing from inspector.

midnight plover
midnight plover
# keen knot ``` private void Start() { videoPlayer.clip = clip; videoPlayer.Play();...
void Update()
    {
        if (isReversing)
        {
            videoPlayer.Pause();

            double newTime = videoPlayer.time - Time.deltaTime;
            if (newTime < 0)
            {
                newTime = 0;
                isReversing = false;
            }

            videoPlayer.time = newTime;
            videoPlayer.Play();
        }
    }

This is what I came up with thats "somehow" working. But you can see, that it struggles with the playback sometimes not reversing or taking sometime before it actually updates the frames and then keeps on reversing. From what I read also on Renderheads AVPro Video package, its just a huge issue to play in reverse because the player will always have to expensively compute the previous frames.
Here are some tips what you could do, but depending on the video, if its not dynamic, you could also think about creating a reversed version and sync two videoplayers for example, which still might be less expensive than running a forward played video backwards.
https://www.renderheads.com/content/docs/AVProVideo/articles/feature-seeking-playbackrate.html?q=Reverse#:~:text=If you want to start changing the playback rate%2C play in reverse%2C allow fast scrubbing%2C or have fast frame accurate seeking then you may run into issues where the playback becomes extremely slow or the seeking is not accurate.

real thunder
#

are there, like, intended methods for animation transition to occur like last/new animations are not playing?

midnight plover
real thunder
#

yes

#

currently I am modifying speed of the state to get the effect but it's kinda cursed

midnight plover
real thunder
#

right, that's not really a code question but more about animator

#

what I am trying to achieve is that walking > stun animation transition like walking is halted - so less movement on legs since they won't make much sense

#

and it works if I set walking state speed zero before transitioning but that looks like there should be a proper way to do so

#

anyway at least that works, now I see the part which does not work

midnight plover
#

#🏃┃animation but maybe continue over there, as you said. thats some kind of animator question

real thunder
#

that would change the look of transition

#

thanks for linking that channel, I ll use it next time I get animator issue

#

actually I would go there rn cause my another issue got code involved but not about code

sour cape
#

somehow suddenly i cant drag multiple audio clips into my AudioClip[] in the inspector, anyone know how to fix?

timber tide
#

make sure no console errors, make sure types correct

sour cape
#

thanks, yeh still no luck, so tedious, i can drag 1 by 1

rich adder
sour cape
#

dragging them as usual onto variable name yeh

sour cape
#

yeh must be a bug in this unity, arrays acting very weird

wheat remnant
#

is there a way in the graph toolkit to have ctx.AddOption with some enum, but only conditionally show?
for example, i have a way for my importer to tell the type of a ScriptableObject game state key, and want it to show the appropriate enum options, such as operations related to bools if the key type is bool, int operations for ints, etc.

essentially, i want to be able to be able to have this, but have it be able to be conditional which actually shows the proper enum based on the key type.

ctx.AddOption<IntCompareOp>("IntOp").WithDefaultValue(IntCompareOp.Equals);
ctx.AddOption<FloatCompareOp>("FloatOp").WithDefaultValue(FloatCompareOp.Equals);
ctx.AddOption<StringCompareOp>("StringOp").WithDefaultValue(StringCompareOp.Equals);```


however, i don't think there's a built in thing for options such as .VisibleIf, at least docs-wise.
wintry quarry
brave tapir
#

I am struggling with twitch integration with unity I dont know if the solutions im trying are too old or what but they keep failing at the user auth stage. Does anyone know of a stable solution? No matter what I do in terms of auth token ,the channel name ,the Client ID or OAuth Redirect URLs I cant seem to get right.

naive pawn
empty ice
brave tapir
# empty ice What do you use to call the API? Manual web requests or an SDK of some sort

I’m using the Dan Qzq Unity Twitch Chat Interactions library. It handles most of the OAuth, chat connection, and API calls for me, so I don’t make manual web requests. The library wraps the Twitch API in C# methods I can call from Unity.
https://github.com/danqzq/unity-twitch-chat-interactions/tree/main

GitHub

A Unity tool that will allow you to easily implement Twitch chat commands into your game! - danqzq/unity-twitch-chat-interactions

bitter ruin
#

Hi , could somebody please help me wih my projekt? I need to know how to use varibles in two differnt scripts .

wintry quarry
bitter ruin
#

ok , have a good day

empty ice
supple phoenix
#

What is the good way to store whether a monster is dead between scenes?

  • Save the id of monster in some kind gamemanager and delete them at scene loaded.
  • Have data in the GameManager that keeps track of which monsters should spawn in each scene and where.
  • Or is there a another way?
wintry quarry
supple phoenix
#

yhym ty

fringe plover
#

Is it even worth it caching WaitForSeconds
Like, i have to have a field for storing WaitForSeconds cuz unity recommends caching it now
Like, whats the point????

I did it here, but with other transitions, like in this pic

#

But here i havent cuz i didnt feel like its worth it

#

is the impact even high enough to even consider caching them?

frosty hound
#

If you're going to reuse something over and over, such as a WaitForSeconds object, there's no harm in caching them.

polar acorn
fringe plover
#

question is:
Is the performance increase worth having a field for each corotine

polar acorn
#

"Is the benefit worth zero effort and no functional change"

#

yes

#

Also, the fact that you're creating it in the function means that you're still making a new one every time

#

So you're not even actually getting a benefit

fringe plover
#

its not a "zero effort" for me
for me it means i need to clog classes with additional fields
so i have to think if its worth it

Also another question, can i reuse same object for multiple corotines, what if i use 1 object at the same time

polar acorn
#

The entire point is to create the wait one time and reuse it

wintry quarry
wintry quarry
#

it really depends how often you're doing this, but it's good to be in the habit of reusing whenever possible. Garbage collection is an insidious silent killer of performance.

midnight plover
frosty hound
#

Create a static object that stores them for reuse. Nice and tucked away. thinksmart

#

But realistically, if your game is small, then it's whatever. It's not going to be the thing that makes your game unplayable.

#

But if you're running that function across many objects at once (AI looking for the closet object), then yes it will matter.

fringe plover
#

I guess

midnight plover
# fringe plover I guess

you could extend this with a dictionary or array to get specific time waitforseconds and create new ones if not existent yet and then you can just pool catch them to be used

fringe plover
#

Yeah no im not implementing that.
I feel like using fields would be easier to handle and they could act as "Configs" so i can change transition speeds and stuff without editing the class with logic

midnight plover
#

And changing transition speeds could still be just your field instead of 1f in my example

tranquil mesa
#

how would i get the gameobject that the script is attached to

naive pawn
#

.gameObject

polar acorn
#

Or just gameObject

tranquil mesa
#

mb i was doing ||public GameObject Character = gameObject;||

naive pawn
#

i mean, that works?

#

it's unnecessary, but it's not like, wrong

tranquil mesa
#

oh yeah ur right

#

ops

lyric igloo
gloomy heart
#

!code Dont send plaintext codes

radiant voidBOT
lyric igloo
#

mb

lyric igloo
polar acorn
gloomy heart
#

Whats Health?

lyric igloo
#

nvm im dumb its just debug it instand of destroy it

lyric igloo
#

how do i make an ai that will chase me?

naive pawn
#

that's a pretty broad topic, start with google

rocky canyon
tender mirage
swift crag
#

(and even if C# let you do that, Unity would not have had a chance to set the object up yet)

#

i'm pretty sure it's illegal to give a MonoBehaviour a constructor that tries to access Unity properties

polar cargo
#

hi how do i start making 2d games because i dont find good tutorials

frosty hound
#

There are plenty of tutorials, the fact you haven't found "good" tutorials is silly.

#

If you want to learn Unity in general, you can go through Unity's own tutorials:

#

!learn

radiant voidBOT
mild reef
#

would this work without mathf. ?

polar acorn
mild reef
#

I mean I guess the answer is yes?

#

probably missing something

solar hill
#

are you getting errors?

#

i mean whats even happening lol

#

youre being a bit too vague for us to help

mild reef
#

theres no errors

#

its just supposed to change the light intensity off of a variable thats it

#

the bool turns on and works but the intensity never changes

slender nymph
#

why are you using fixedDeltaTime inside of Update? that's going to be affected by the framerate

mild reef
#

but should still work?

polar acorn
#

Try logging it after you change it

mild reef
#

yeah that doesnt help, logs still said everything should be working

mild reef
#

theres some type of issue with that specific thing

polar acorn
#

Did the value increase when you logged it?

mild reef
#

no

polar acorn
#

What did you log, and where?

mild reef
#

the value itself has not changed at all, I see it in the inspector

#

I logged when the bool is fully on and when it was told to go on, and both went off

#

the light intensity stays at 0

polar acorn
#

Show your code with the logs included

mild reef
#

it has something to do with the time.fixeddeltatime it worked without it

#

I need it to work overtime though

polar acorn
# mild reef

Instead of just logging text that tells you nothing useful, log the value of mylight.intensity

mild reef
#

you realize it shows in the inspector right?

#

and I can clearly see it

polar acorn
#

And you realize that there is zero indication that what you're looking at in the inspector is even the same light

#

Log it.

#

Stop assuming, check.

mild reef
polar acorn
mild reef
#

its not

polar acorn
#

Do the logs show that?

mild reef
#

mathf would be to change it overtime

polar acorn
mild reef
#

smh nvm

polar acorn
#

So, when you log the value of mylight.intensity, what does it say

verbal dome
# mild reef

You'll have a much more pleasant time coding after you configure your !ide

#

!ide

radiant voidBOT
lyric igloo
#

why my death animation not working? its showing at all the the first frame of the death animation and when its dead shows nothing heres the codehttps://paste.mod.gg/ucvvolxhsrhv/0

hallow adder
lyric igloo
#

so how i fix?

hallow adder
#

delete "death" boolean in the animator parameters, add "death" trigger, then fix the transition to use the trigger

#

or if death is intended as a boolean, edit code to use SetBool instead

swift crag
#

right now, the "Death" parameter starts out true, and nothing causes it to ever become false

#

so the transition from 'Any State' to 'death' is always valid

#

(and by default, this transition is allowed to run even if you're already in the 'death' state)

#

therefore, it restarts the animation every frame

lyric igloo
#

its working thanks yall

wheat remnant
pliant dome
#

It seems that no matter what I do my jump animation always either plays for one frame then goes back to idle, running, or walking animation in mid air. Ive tried to do everything in my power to have the jump animation prioritized first and foremost but it never does

#

Can someone help me wit this?

pliant dome
#

Nothing is eally going on in there. Im using alot of animator.Play in the script. Everytime I tried to use the animator it would turn into a massive spider web and it would not work out the way I want it to

#

I was hoping to use booleans in the animator to prevent the grounded animations like idle, walk, and run from playing but no matter what it doesnt do as I intended

swift crag
#

If you don't have any transitions, then the animator will only change states if you tell it to via Play(). so, go ahead and share that

pliant dome
#

Its super messy

#

just ignore that and go to the animation methods

#

Thats where I handle all my animations

swift crag
#

I would make sure that onGround is getting set correctly

#

notably, you're using a pretty long raycast in getisGrounded

#

and you don't check if your velocity is negative (or at least not positive)

#

so this method will say you're grounded even while you're moving up at the start of your jump

#

which will immediately cause you to play a walking/idle/running animation

pliant dome
#

YEah thats why what i was trying to do is have the box collider work along side the raycast for whenever Im off the groud but also have another bool that determines when Im off the ground by only using the box collider

#

thats why I have the onGround

swift crag
#

oh, isGrounded and onGround are two different variables

pliant dome
#

Yeaj

#

yeah

swift crag
#

You should still check what the actual value is. Maybe log the relevant values at the top of Animation2().

pliant dome
#

True Im gonna actually make the raycast longer to test something

#

Can confirm in the inspector that the onGround is unchecked first when I jump then the isGrounded

solar hill
#

is there any reason you have 2 variables that pretty much describe the same thing?

#

🤔

pliant dome
#

I do!

#

So this is a platform fighter and when you airdash into the ledge and have the collider collide with the ground you become grounded even though your in the air and so having raycast allows me to pick and choice which true or false things happen when I jump off the ground or when I land

#

Like resetting the jump count or airdash count

#

requiring both the raycast and the box collider to touch the ground makes it so that I still need to land on top to reset jumps but prevent jump count resetting wwhen jumping next to the ledge

#

Also I still couldnt figure out how to have the jump take priority. I actually solved this issue before back when I was only using the box collider and not using a raycast along side the collider

#

but honestly I have no idea how I even solved that

#

or at least I dont understand how it fixed it. I tried replicating the same thing but nothing happens now

tranquil mesa
#

is there a neater way to write this

        if (IsGrounded)
        {
            newVel = new Vector3();
        }```
eternal needle
tranquil mesa
#

Isnt that js reversing it

cosmic dagger
#

You asked for neater . . .

#

The only thing that changes is the y value, so change it if you're not grounded . . .

lyric igloo
polar acorn
lyric igloo
#

yes i am and yes but ill recheack

#

yeah its fine

polar acorn
#

Try logging targetAnimator and see what object it's detecting

hallow adder
#

logic seems backwards. Bullet has an animator with "impact", but your code for bullet tries to play "impact" on Enemy. Enemy's animator probably doesn't have "impact"

pliant dome
#

Dude I can't figure out why the idle, walk, and run animations take such high priority over only the first jump? 😭😭

pliant dome
#

it plays for like one frame then it stops

tired python
#

when i make a clone of Droplet prefab instance, the clone's Bullet Pool Container starts out empty

#

like this

sour fulcrum
#

While it's in the name just a heads up that Clone isn't reallyyy used much in documentation/reference so might confuse people, usually Instance is used. With that in mind, When you say your "making a clone of a prefab instance", are you instansiating a prefab asset, or a prefab instance?

tired python
sour fulcrum
#

ok so just a heads up, Instance would be the thing that exists in the scene, either placed manually in editor mode or spawned via code. a reference to a Prefab from your /Assets/ would be a Prefab Asset

#

mentioning this because using the right terms better for explaining and researching

#

on that note

#

Ideally you'd be dragging in the prefab from /Assets, not one that's just in the scene

tired python
#

so it should be called the prefab instance no?

#

"Instance would be the thing that exists in the scene, either placed manually in editor mode** or spawned via code**"

#

oh wait, the clone is the instance

#

mb

sour fulcrum
#

Yes, your problematic one is an instance, but the one your referencing in your serializedfield is currently also an instance from the scene, which you might want to be instead a reference to the prefab Asset (?)

ivory bobcat
tired python
sour fulcrum
#

both in the top pic are prefab instances

tired python
#

alright

sour fulcrum
#

you probably want to be referencing the prefab asset in your pool

waxen adder
#

Is there some way to make a dynamic rigidbody completely immovable without setting it to kinematic OR applying constraints?

ivory bobcat
thorn holly
ivory bobcat
#

In knowing so, the solution can better cater towards what you're needing.

waxen adder
thorn holly
waxen adder
#

When collided with

ivory bobcat
thorn holly
#

i think

#

idk try it and see

waxen adder
#

Oh, another thing I want to know is if it's possible for two dynamic bodies to not push each other if they move into each other

thorn holly
thorn holly
#

do they both just stop completely?

ivory bobcat
#

That would be a different kind of physics so unless you implement it yourself, you'll probably get some level of shoving unless they're so massive that it's practically impossible to be moved etc

thorn holly
#

not really a great solution here

waxen adder
thorn holly
#

its why kinematic and static exist

thorn holly
#

can u give an example

waxen adder
#

If it helps, I have a player controller in mind where their movement is pretty rigid, like what happens with character controllers, but they can situationally act on or apply forces.

My thinking is probably a custom controller that has a character controller as a baseline, but I'm trying to see if finessing a rigidbody could work.

thorn holly
#

thats prolly the closest to what you want

waxen adder
thorn holly
#

if i have two collide in this way theyd slide off, though it looks more like pushing since its a very short collision

waxen adder
thorn holly
#

so hopefully someone else can help u lol

waxen adder
#

Ah lol no worries

ivory bobcat
#

If anything, without having to reinvent an entire system, you could probably have some other object with a kinematic body follow each the players (using a parent constraint component) that would prohibit the other objects from pushing it. Whilst ignoring it's own player object, that is.

#

This implies that object would have some collider slightly larger than the players to prohibit any interaction between players.

waxen adder
tired python
#
[SerializeField] BulletPool bulletPoolContainer;
void update(){
  // if a certain condition is met
  GameObject Tempbullet = bulletPoolContainer.DropletBulletpool.Get();
}```

public class BulletPool : MonoBehaviour
{
[SerializeField] private GameObject _dropletPrefab;
public ObjectPool<GameObject> DropletBulletpool;

private void Start()
{
    DropletBulletpool = new ObjectPool<GameObject>(CreateDropletBullet, GetDropletBulletFromPool, 
                                                    ReturningDucktoPool, OnDestroyDuck, true, 20, 10);
}

}```
Tempbullet shouldn't be null even if the DropletBulletpool has nothing in it because the pooling mechanism creates an instance and returns it right?

eternal needle
ivory bobcat
tired python
eternal needle
#

you define the method CreateDropletBullet, it does what you tell it to

tired python
#
{
    GameObject DropletBullet = Instantiate(_dropletPrefab, _dropletPrefab.transform.position, Quaternion.identity);
    return DropletBullet;
}```
eternal needle
#

if something isn't working as you expect, add logs or specify your error. I have doubts the issue is what you think it is

tired python
#

guess what, it's not working, apparently Tempbullet ain't working

ivory bobcat
#

Define "ain't working"

#

Are you receiving an nre?

tired python
#

null reference

ivory bobcat
#

Can you show the error log?

#

(basically what line is causing the error)

tired python
#

wait, i am debug logging it

#

this line

#

27

#

it is null as it should be

ivory bobcat
#

An nre occurs if members are not accessible. If it's occurring on line 27, the container or pool may be null

tired python
#

it's not reaching the part of the BulletPool which creates an instance

thorn holly
#

unity has a built in object pooler?

#

intersting

tired python
ivory bobcat
# tired python this line

Properly post code so that I do not have to squint and manually type characters (no images please unless absolutely necessary - ide/editor bugcs Debug.Log($"Container: {bulletPollContainer}"); Debug.Log($"Pool: {bulletPollContainer.DropletBulletpool}"); Debug.Log($"Container: {bulletPollContainer}");

tired python
# ivory bobcat Properly post code so that I do not have to squint and manually type characters ...
using NUnit.Framework;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Pool;

public class EnemyCollision : MonoBehaviour
{
    [SerializeField] string DuckTag;
    private List<Transform> EnemyList;
    [SerializeField] Bullet bullet;
    [SerializeField] float ReloadTime;
    [SerializeField] float Damage;
    [SerializeField] float BulletSpeed;
    [SerializeField] float BlastRadius;
    [SerializeField] BulletPool bulletPoolContainer;
    private float _reloadTime = 0.0f;
    private void Start()
    {
        EnemyList = new List<Transform>();
    }
    private void Update()
    {
        //if ready to shoot and there are enemies present in range
        if (_reloadTime >= ReloadTime && EnemyList.Count != 0)
        {
            Debug.Log($"Container: {bulletPoolContainer}");
            Debug.Log($"Pool: {bulletPoolContainer.DropletBulletpool}");
            //create a bullet
            GameObject Tempbullet = bulletPoolContainer.DropletBulletpool.Get();
            Debug.Log($"The Tempbullet is: {Tempbullet.tag}");
            Tempbullet.SetActive(true);
            //Bullet Tempbullet = Instantiate(bullet, this.transform.position, Quaternion.identity);
            Bullet bullet = Tempbullet.GetComponent<Bullet>();

            bullet.SetPool(bulletPoolContainer.DropletBulletpool);
            bullet.Initialise(EnemyList[0], Damage, BulletSpeed, BlastRadius);

            _reloadTime = 0.0f;
        }
        _reloadTime += Time.deltaTime;

    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == DuckTag)
        {
            Debug.Log("Duck was detected.");
            EnemyList.Add(collision.transform);
        }
    }
    private void OnTriggerExit2D(Collider2D collision)
    {
        EnemyList.RemoveAt(0);
    }
}```
#
using UnityEngine;
using UnityEngine.Pool;

public class BulletPool : MonoBehaviour
{
    [SerializeField] public GameObject _dropletPrefab;
    public ObjectPool<GameObject> DropletBulletpool;

    private void Start()
    {
        Debug.Log("Reached here.");
        DropletBulletpool = new ObjectPool<GameObject>(CreateDropletBullet, GetDropletBulletFromPool, 
                                                        ReturningDucktoPool, OnDestroyDuck, true, 20, 10);
    }

    GameObject CreateDropletBullet()
    {
        GameObject DropletBullet = Instantiate(_dropletPrefab, _dropletPrefab.transform.position, Quaternion.identity);
        return DropletBullet;
    }

    private void GetDropletBulletFromPool(GameObject droplet)
    {
        droplet.SetActive(true);
    }

    private void ReturningDucktoPool(GameObject droplet)
    {
        droplet.SetActive(false);
    }

    private void OnDestroyDuck(GameObject droplet)
    {
        Destroy(droplet);
    }
}
tired python
#

Container: Pool (BulletPool)
UnityEngine.Debug:Log (object)
EnemyCollision:Update () (at Assets/Scripts/Collision/EnemyCollision/EnemyCollision.cs:26)

sour fulcrum
tired python
#

Pool:
UnityEngine.Debug:Log (object)
EnemyCollision:Update () (at Assets/Scripts/Collision/EnemyCollision/EnemyCollision.cs:27)

tired python
# sour fulcrum why do you think this

cus initially, there are no bullets at start, it's only when the enemy enters range, that it starts firing so although, the pool is instantialised, there are no instances present in it

sour fulcrum
#

empty != null

ivory bobcat
tired python
#

oh...

#

so i am guessing that it isn't being referenced the right way or smth?

slender nymph
#

is the BulletPool object you are referencing a prefab or an object in the scene

slender nymph
#

that's the issue then, if it isn't in the scene then Start has never been called on it therefore it never instantiates the actual ObjectPool object

ivory bobcat
# tired python its the `prefab asset`

Just for clarity, let's refer to the term prefab as objects in the scene. Once an object is instantiated from a prefab, it's an instance of that prefab and not actually a prefab. This applies to objects already in the scene as well. If they're already in the scene, they aren't refer to as prefabs.

tired python
slender nymph
#

something else is doing that then. or you've got a BulletPool in the scene which is what you would need to be referencing instead

tired python
#

so, it does end up printing this

ivory bobcat
tired python
#

the prefabs are referencing each other, so although the Droplet is instantiated, since the Pool isn't, it doesn't reference the Pool prefab

slender nymph
#

even if it did reference the Pool prefab, that prefab never has Start called on it

ivory bobcat
tired python
tired python
slender nymph
#

so the "Pool" prefab does not have the "BulletPool" component on it? because that has a Start method that is only called when the object exists in the scene

tired python
#

wth do i do then

slender nymph
tired python
tired python
#

did not work though, cus the clones weren't referencing the Pool when instantiated

slender nymph
#

have the pool in the hierarchy. then, like i told you the day you first asked about doing this, have whatever spawns the turret objects pass the pool to the spawned turret objects when it instantiates them

tired python
slender nymph
#

where

tired python
slender nymph
ivory bobcat
#

So just for clarity, on this line bulletPoolContainer.DropletBulletpool.Get the bulletPoolContainer (likely a prefab asset reference rather than the one you're expecting from the scene hierarchy) has it's member DropletBulletpool as null.

tired python
slender nymph
#

show how you tried to do that

ivory bobcat
#

So instead of referencing the prefab assetbulletPoolContainer, actually reference the scene object.

tired python
slender nymph
#

so you didn't do what i said. i specifically called out passing the reference to the instantiated object and did not say "rely on cloning the object to still reference the right object" because doing that would mean you have to clone the scene object but ideally you would be cloning a prefab instead

ivory bobcat
#

It should be an object in the scene (not an asset prefab)

tired python
ivory bobcat
slender nymph
tired python
#

in the Bullet itself

#

cus i did set

private void Update()
{
    //if ready to shoot and there are enemies present in range
    if (_reloadTime >= ReloadTime && EnemyList.Count != 0)
    {
        Debug.Log($"Container: {bulletPoolContainer}");
        Debug.Log($"Pool: {bulletPoolContainer.DropletBulletpool}");
        //create a bullet
        GameObject Tempbullet = bulletPoolContainer.DropletBulletpool.Get();
        Debug.Log($"The Tempbullet is: {Tempbullet.tag}");
        Tempbullet.SetActive(true);
        //Bullet Tempbullet = Instantiate(bullet, this.transform.position, Quaternion.identity);
        Bullet bullet = Tempbullet.GetComponent<Bullet>();

        **bullet.SetPool(bulletPoolContainer.DropletBulletpool);**
        bullet.Initialise(EnemyList[0], Damage, BulletSpeed, BlastRadius);

        _reloadTime = 0.0f;
    }
    _reloadTime += Time.deltaTime;

}```
#

i did pass a reference to that pool then

slender nymph
#

and what about to the object that is literally throwing the NRE? because that's a different object

#

like it's literally the one you are posting code from. that needs the reference

tired python
#

so...i make a reference to the pool wherever the object which this Update() is present in is instantiated from?

slender nymph
#

yes, this object needs the reference to the existing BulletPool object. so pass it to this object when this object is spawned.

tired python
#

ahhh

slender nymph
#

this is the turret object, yes? that's what i told you to pass the pool to in the first place

tired python
slender nymph
#

at no point did i say that the turrets need to be in the pool

tired python
#

i ain't applying pooling system to the turrets yet, only the bullets

slender nymph
#

they need a reference to it, not to be in it

tired python
#

wait lemme figure it out then

waxen adder
#

I noticed that when using a character controller, there's a gap between them and things they're colliding with. Walls and the ground are the big things where I'm seeing this. Any ideas on how to get it closer to actual touch?

slender nymph
#

pretty sure that's the skin width

waxen adder
#

Ah right. Any issues with the value being super low?

hot wadi
#

Why don't u mess with it and see how it turns out

tired python
#

@slender nymph @sour fulcrum thx, it's working now

#

how cooked is this?

#

should i make the bullet separate from the Droplet?

tender mirage
#

Hey there. i've been trying to experiment with a wall jump script, but i'm having trouble getting the oppisite Y rotation of the current Y rotation, which would make the character face their backside as soon as they performed a wall jump, but they aren't turning properly most of the time, especially when they're on 0 degree's you can't really say -0 to get the oppisite rotation


//If walljump triggered
if (playerJump.triggered)
{
    //Only allow if can walljump and ishugging wall
    if (isHuggingWall && canWallJump)
    {
        //Get forward 
        Vector3 playerForward = transform.forward * 40;
       
        //Get new velocity
        Vector3 wallJumpVelocity = -playerForward + new Vector3(0, 50, 0);


        //Apply velocity
        playerRigid.linearVelocity = wallJumpVelocity * 2;


        //Play jump combo sound for now
        playerSound.JumpComboSound(jumpCombo);


        //Get current angleY
        float currentRadY = transform.rotation.y;

        float targetAngleY = -currentRadY * Mathf.Rad2Deg;
        
        //Apply rotation
        transform.rotation = quaternion.RotateY(-targetAngleY);
    }

}
sour fulcrum
#

i could be mistaken but adding 180 to any current rotation will just go the other way, no?

ivory bobcat
rough granite
tender mirage
sour fulcrum
#

unity does all that

tender mirage
#

ahh, so if you set a value above maximum degree

#

unity does the job on the rotation values

#

got it

sour fulcrum
#

if im wrong someone will correct me but yeah it should resolve it into whatever its meant to be in the range

#

i've actually never 100% looked into it myself but i wanna say thats -360 to 360? since positive negative is used for direction?

tender mirage
#

I didn't get any errors so yeah, it should be like you described

#

For some reason at max i'm getting 60 degrees when i turn around completely, and thats about it

#

i'm definitely doing something wrong which sucks

#

getting 0 to 60 turning from start point to the right side to my back and from their it's minus

ivory bobcat
#

Did you remove the few lower lines that attempt to make use of the quaternion y component?

#

The quaternion consists of x, y, z and w components. It isn't likely what you think it is.

tender mirage
#

I'm only rotating the Y value tho right?

#

that should be clearly the right choice

ivory bobcat
#

It isn't what you think it is

tender mirage
#

what the heck, it's x? why did i think it was y

#

wait nvm i'm just losing it, it is y

sour fulcrum
#

rotations are weird for complex reasons, generally you'd want to use

.rotation = Quaternion.Euler(x,y,z);

to handle it like you would position and scale

tender mirage
sour fulcrum
#

reading them is the same yeah, just setting them needs some help

tender mirage
#

so it's perhaps the rotateY function you're suggesting is causing that. alright

#

i'll try it

ivory bobcat
#

A quaternion is a four-tuple of real numbers {x,y,z,w}. A quaternion is a mathematically convenient alternative to the euler angle representation.
...
Note that Unity expects Quaternions to be normalized.
The four components of a Quaternion are not what you think they are.
https://docs.unity3d.com/ScriptReference/Quaternion.html

tender mirage
sour fulcrum
#

hopefully this isn't a poor explaination but basicially unlike position and scale rotation fundementally has some context/history related to going from one value to another

#

because lets say you spin yourself to move north

#

there's multiple ways you could do that

tender mirage
#

like how lerp has slerp, or smoothdamp has umm well it has it too with a certain name, which calculates the path of rotation

#

is that what you're talking about?

ivory bobcat
tender mirage
ivory bobcat
#

Logging the rotation property should immediately reveal that the numbers may not be what you'd expect.

tender mirage
#

it's very interesting tho. Get's complicated really fast, just read abit about it and nope, like you said, i don't need to learn math for this

#

lol

ivory bobcat
tender mirage
#

lemme see

tender mirage
#

thanks for the help

ivory bobcat
#

When you read the .eulerAngles property, Unity converts the Quaternion's internal representation of the rotation to Euler angles. Because, there is more than one way to represent any given rotation using Euler angles, the values you read back out may be quite different from the values you assigned. This can cause confusion if you are trying to gradually increment the values to produce animation.
...
To avoid these kinds of problems, the recommended way to work with rotations is to avoid relying on consistent results when reading .eulerAngles [...]
Best to just keep a Vector 3 field. Modify and do arithmetics to said field. And write directly to the rotation property using Quaternion.Euler if you're needing to change the value. Else Quaterion has some common overloaded operations for adding or
subtracting rotations.

tender mirage
#

You would think this would work but i'm still getting inaccurate rotations

//Get reverseY
float reverseY = Quaternion.Inverse(transform.rotation).y * Mathf.Rad2Deg;
wintry quarry
#

you should never be touching the .y of a Quaternion like this

ivory bobcat
#

You're still attempting to make use of the normalized quaternion y value.

wintry quarry
#

or any of the internals

#

Say it with me:

Quaternions are not euler angles

tender mirage
#

Yeah it's the normalized value translated to degrees which gives off the illusion that i'm getting the actual degree but i'm inaccurately just grabbing the normals huh?

wintry quarry
#

it's not a "normalized value". It's a quaternion component which doesn't relate directly to euler angles at all

timber tide
#

Also:
Say no to euler angles

ivory bobcat
timber tide
tender mirage
#

Alright.

ivory bobcat
tender mirage
#

It's weird tho. i'm getting half of the degrees right and the other half is just wrong.

#

As you can see. above 180 it doesn't go to minus like the actual objects rotation

ivory bobcat
#

What's the current code?

tender mirage
#
//Get current angleY
float angleY = transform.localRotation.eulerAngles.y;
#

Basically this.

ivory bobcat
#

Right, looks fine.

tender mirage
#

maybe the quaternion inverse would work this time? lemme try it

ivory bobcat
naive pawn
#

-108.762 and 251.238 are the same angle

#

it's just a matter of how it's displayed

tender mirage
#

i see.

naive pawn
#

the true representation of the rotation is the quaternion. if you turn that into degrees, then there's not really a 'canonical' angle
obviously 720 isn't canonical, but is -90 or 270 more correct? if using negatives, should it be 180 or -180? etc

but it really doesn't matter if you're just doing math, just that you need to treat angles correctly.

tender mirage
#

alright i'm not religious but, prayers this will work

//Get current inverse angle
float angleYInverse = Quaternion.Inverse(transform.localRotation).eulerAngles.y;
naive pawn
#

and if you're using it to display stuff, it depends on what would be more useful to display

#

imo in the editor, negative angles would be better, and from code, yeah having non-negatives for debugging purposes seems to make sense

tender mirage
tender mirage
naive pawn
#

rotations are confusing in general 😮‍💨

#

i mean, on the surface, yes it's pretty intuitive. but once you start getting into the math and representations and algorithms.. there's a lot more than one might expect

tender mirage
#

definitely. i'm honestly alot more comfortable with 3D space forward and right with transform to be honest and you can do alot of cool stuff with that

tender mirage
swift crag
#

oh wait, I thought you were doing this :p

transform.rotation.y
#

(that's the really common one)

naive pawn
#

they had something similar at one point

swift crag
#

but yeah, individual Euler angles can be very misleading

#

your Y rotation affects the meaning of your X and Z rotations, and your X rotation affects the meaning of your Z rotation

tender mirage
swift crag
#

I rarely actually use them directly

#

Quaternion and Vector3 have many useful methods

#

e.g. Vector3.SignedAngle

timber tide
#

Usually you can get away if you only modify like Y and X, but once you touch Z then euler just lies to you

#

can get away with a lot more things in 2D that's for sure

swift crag
#

I try to never actually modify the euler angles

naive pawn
#

this is a code channel

rugged bay
#

oh sorry, I got the wrong channel.

earnest wind
#
SecondsSet += seconds;
if (SecondsSet > 86400) SecondsSet = 0;
int h = SecondsSet / 3600;
int m = SecondsSet % 3600 / 60;
int s = SecondsSet % 60;

PlaceholderCountdownText.text = $"{h:D2}:{m:D2}:{s:D2}";

SecondsRemaining = SecondsSet;

long unixNow = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
targetUnix = unixNow + Mathf.RoundToInt(SecondsRemaining);

which part of this code is the most performance reducing?

#

i notice a total 1 second freeze when i do this function, even if seconds is 60s or 6000s, same 1 s freeze

#

also, when doing it for the first time*

#

after that it does not lag anymore, weird, cant replicate on pc

#

only on android

#

is it that accessing UtcNow initializes smth ?

wintry quarry
#

But you should use the profiler to confirm

earnest wind
naive pawn
#

couldn't it also possibly be the redrawing of the canvas?

wintry quarry
#

You need to use the profiler.

earnest wind
#

let me check

earnest wind
#

0.8kb is that bad for gc??

grand snow
#

no its not and you would see a large gc collect operation if the lag was the garbage collector working

#

I think more context is needed

teal viper
#

For starters a frame with the lag spike sorted by cpu time.

slow blaze
#
           foreach (string word in answer)
            {
                if (target.Contains(word, StringComparer.OrdinalIgnoreCase))
                {
                    Debug.Log("Found word: " + word);
                }
                else
                {
                    Debug.Log("Not found: " + word);
                }
            }
            return true; // All words matched
            
        }```
I have a list of string (answer) that I want to check if all the elements in it matches the elements in another list of string (target)
it isn't working as intended as there are some words that are present yet get detected as not found
any help with that?
keen dew
#

Show an example of the two lists that don't work as intended

swift crag
swift crag
#

Can you profile this on-device?

#

i wonder if something else is hitching

earnest wind
wintry quarry
# earnest wind

You need to find the frame with the spike and look at that.

candid pilot
#

İ am making a fps game and i used cameta stacking for weapon clipping. The camers that renders the weapon layer cause performance issue. And yes i am sure that main camera doesnt render the weapon layer.

#

Is there any optimization trick about that

solar hill
#

renderer features

#

avoids the 2 camera thing entirely

#

also mix that in with reactive occlusion through ik and you get a nice looking anti clipping system

candid pilot
#

Nice i will give it a try

#

Thanks for the respond

#

Btw did u make it using animation rigging?

solar hill
#

like i said

#

runtime ik offsets.

swift crag
#

pulling the weapon back as you approach a wall looks really nice

edgy sinew
solar hill
#

it works by progressively blending an animation curves rotational offsets toward a target intensity and applying them each frame as a small rotation on the camera itself

edgy sinew
#

Hi all, so I wrote some code using the Playables API, pretty simple stuff from the few YouTube videos about that.

mixerPlayable.SetInputWeight(0, 1f - weight);
mixerPlayable.SetInputWeight(1, weight);
clipPlayable.SetTime(0.0f);
playableGraph.Play();

❓ I am wondering, why is there such a noticeable pop / snap when changing animations, especially with the legs / feet?

Even if I keep the weight at 0, the character snaps back into place into the same Idle animation 🤷‍♂️
I tried going from Idle to the other animation in the Animator ("Make Transition") and it doesn't have this issue.

solar hill
#

the snap back might be due to the root position of the animator

edgy sinew
#

I read that this can happen if the skeletons don't match exactly,
But then why does the Animator not have this issue? Perhaps it does some extra stuff to prevent that 🤔

pliant abyss
#

Getting Component from an Object in root

worthy veldt
torn wraith
#

Is this alot of scripts for a small game? Should I organize them into one more folder space?

gloomy heart
#

You can organize them into folders like PlayerControllers , ui handler etc

frail hawk
#

yeah as it was recommended, you could group things and use folders

gloomy heart
#

What i do is organize them using namespaces

torn wraith
#

oh ive used those before, but how does namespace work andhelp me?

gloomy heart
#

I don't if my strategy is efficient or optimum but i do one global namespace like Project_Name{} and them use sub namespaces for work by creating sub namespaces that contain classes related to only UI stuff or Player Controls and their sub namespaces for divsions under those sub categories, and oganize files by namespace names like PlayerUtils, UI and then their sub namespace name folders, like Player Controllers, ButtonPressHandler{} etc

dark brook
gloomy heart
quartz tulip
#

Ok this is my first project using unity and I don't know what on earth is going on. Basically, in my game there is two game modes that you can switch between, so I created a Scriptable Object class called GameData so that I could keep the save in between modes, so when I came to the problem of having to save the game to a json, I thought it would be relatively easy, by just saving what is in the GameData to the json then reassigning it once the game is started again, but for whatever reason, when I mention "data" (the actual GameData object) in any form rather than doing data.waveNum for example, it completely skews the data? I had this error before but managed to fix it by just not referencing the data at all in the code. It's very hard to explain so here's an unlisted YT video I made about it.

https://youtu.be/XESsBGCSgsU

After recording this, once I took those two commands I put in back out, the data was still skewing so like I genuinely have no idea what's going on anymore, even chatGPT doesn't know what's happening. Ask me if you wanna see any scripts or parts of the code to help solve it I'll try reply as soon as I can. Please help me this is for my college coursework due in literally 2 days, thank you so much!

blissful stratus
#

can any one tell me how can i create a good boss fight not about the move set about the coding

#

like give me a toturial or smth

#

i searched but i couldnt find smth good

fickle plume
#

@blissful stratus This is a code channel. If you want to talk game design create a thread in #💻┃unity-talk

blissful stratus
fickle plume
vernal kiln
#

can anyone reccomend a tutorial for c#? all the ones im finding are useless

fickle plume
vernal kiln
#

thanks

sterile thistle
#

how to use MCP?

warped sierra
#

How can I resolve a firewall issue in Unity Editor that's blocking external communications outside of my local IP address? The firewall only works if I compile at runtime.

rough swallow
#

Hello, I keep facing an issue every time I try to enter Playmode saying "All compiler errors have to be fixed before you can enter Playmode".
Any idea how to fix this?

fickle plume
#

You need to fix all compiler errors.

#

Check that you didn't hide error logs on console.

rough swallow
#

Lemme screenshot it rq

fickle plume
#

Hide buttons top right on the console

rough swallow
#

My pc is struggling to open discord with 16 GB RAM so I just took a photo instead

frail hawk
#

blank error not bad

gloomy heart
rough swallow
rough swallow
frail hawk
#

show code

gloomy heart
rough swallow
#

Don't mind the sun hitting the screen

frail hawk
#

dude

#

seriously learn to take screenshots (not photos)

gloomy heart
#

WHy is update commented?

rough swallow
#

It's full

frail hawk
#

but what does discord have to do with taking a screenshot though

rough swallow
frail hawk
#

and how are you chatting with us without discord

rough swallow
rough swallow
naive pawn
#

so you have an account

#

you can log in in the browser

#

you don't need to download anything extra

solar hill
#

also while discord is a notorious resource hog, you should still be able to open it along side other programs with 16gb of ram

#

sounds to me like your cpu might be getting bottlenecked here not the ram

frail hawk
#

bro probably has a ton of background miners running

rough swallow
#

visual studio taking 1G of RAM too

frail hawk
#

sounds normal

rough swallow
frail hawk
#

16Gb is huge i think there must be something else.

rough swallow
frail hawk
#

dont want to offtopic too much but maybe format your system

rough swallow
cunning narwhal
#

I feel so completely stupid but I cannot for the life of me figure out what is calling the Unity default example class method ShowExample() from the Create > UI Toolkit > Editor Window wizard resulting .cs file

What the heck is calling this method and why does it work when it doesnt appear to be a reserved Unity method (such as CreateGUI())?

Is it the MenuItem attribute that calls it as an entry point and afterwards the normal lifesyscle methods take their turn?

teal viper
tawdry helm
#

(2D project) I'm trying to make a bullet that lowers health by 1 and then is destroyed on contact with the player but Unity is giving me an error saying the namespace for playerHealth couldn't be found.

#

The bullet is using

       if (other.gameObject.tag == "Player"){
           other.gameObject.GetComponent<playerHealth>().HealthUpdates(-bulletDamage);
           Destroy(gameObject);
       }
   }```
#

playerHealth is on a script attached to the player as "private int playerHealth = 0;" with "playerHealth = playerMaxHealth;" at void Start

#

also both scripts are using System.Collections and System.Collections.Generic

naive pawn
#

the <> part takes a type, not a field

#

you need to put in the type of the component

#

playerHealth is not the component, it is a field of the component

tawdry helm
#

Oh

naive pawn
#

the namespace for playerHealth couldn't be found.
that's also certainly not what the error is saying, try giving it a reread 😉

tawdry helm
#

It works now! Thanks!

prime cobalt
#

Is there a way to raycast to a specific face on an object? Also is there a way to see if 2 of an object's faces are connected via an edge?

trim quarry
#

for some reason new input system doesnt work for me

#

i linked this command to player input and to input action events, but still it doesnt work

#

the logs doesnt show up

naive pawn
trim quarry
#

wait

#

the player input

naive pawn
#

is it just that action or are the other actions also not working

trim quarry
#

and event linker

naive pawn
#

ok, you don't need both here

trim quarry
naive pawn
#

it's not going to make the player input work, it's just doing the same work again

naive pawn
trim quarry
#

i dont know how i can do it correctly

#

im new to this

#

the game was using the old inputs

#

and i decided to migrate it to new one

naive pawn
#

you shouldve gotten a prompt to change the input backends

#

check project settings > player > input handling

trim quarry
#

ok

#

yeah its set already

naive pawn
#

to be clear, you aren't getting that "Jump" log, right

#

is this script on an active object in the scene

trim quarry
#

yeah

#

yes

naive pawn
#

check the input debugger, to make sure your hardware input is being recieved

trim quarry
#

how do i check it

#

i opened it but

naive pawn
#

open the keyboard one and make sure it responds when you press buttons on your keyboard

#

specifically the button for jumping

#

you've set bindings for the inputactions, right?

trim quarry
#

yeah it does detect

trim quarry
#

i guess its engine bug

#

ive set everything correctly

naive pawn
#

under the proper control scheme

trim quarry
#

wait

#

i guess the problem in the scene itself

#

when i go to the game, the menus and inputs cant be detected

tawdry helm
#

extremely basic question but I'm trying to make a ball invert its linearvelocity vector2 in X when hitting a wall but keep its Y velocity but I am drawing a blank on how to do it

#

My guess was something like "rb.linearVelocity = new Vector2(? , ?) * speedf;"

solar hill
#

this is in 2d yes?

slender nymph
#

* -1

tawdry helm
#

Yeah still in 2d

#

oh

slender nymph
#

only multiply the axis you want to reverse though

cosmic dagger
#

invert is just the opposite or reverse . . .

#

so whatever the value is, flip it . . .

solar hill
#

but yeah you were like 90% of the way there on your own

tawdry helm
#

Thanks!

naive pawn
vocal veldt
#

idk what happened but unity just magically forgot what the onClick event is

#

the script was working before but then i renamed it to MenuHandler and now onClick won't show up

slender nymph
#

you probably have your own class called Button, notice how using UnityEngine.UI; is grayed out, that means the Button class you are using in this code is not from that namespace

vocal veldt
#

i made a script called Button but i changed it to ButtonOverrides

slender nymph
#

but have you saved/compiled that change?

cosmic dagger
slender nymph
#

that too

vocal veldt
#

ok it's working now thank you

slender nymph
#

changing the name of the file does nothing at all to the code inside the file. if you need to change the name of one of your own types then use the refactoring tools within your IDE to do it so that it can rename the file along with any references to that type

cosmic dagger
# vocal veldt ah

if you want to have your own, just place the class in a namespace . . .

vocal veldt
#

well it's just a script for a tween animation when the mouse enters it

tawdry helm
long sparrow
#

Hi guys does anyone know how to make a countdown timer? I have code provided and copy and pasted it into my script and added the counttext into the player controller but when I go to play the text says “count text” instead of the timer actually counting down from 60 seconds

ivory bobcat
#

Usually you'd provide actual context to get help

#

!ask

radiant voidBOT
# ivory bobcat !ask

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.

-# For more posting guidelines, go to #🌱┃start-here

ivory bobcat
#

Most importantly the last few statements

solar hill
long sparrow
#

😭 there were directions on where to copy and paste it tho so I followed that

solar hill
#

directions?

#

was it Ai written code?

grand snow
#

probably is or a tutorial they miss followed

long sparrow
#

No it’s for an assignment but I figured it out it’s bc it told me to put the code after the void start and I thought that meant inside lol

cosmic dagger
crude prawn
#

Does anyone know how to fix animations being stuck when I'm switching weapons? I have exit time off and I even set the bool to false.

wicked cairn
crude prawn
quiet pollen
#

I am trying to use the same damage script on a gun for both boss enemies and normal enemies, but because they use different scripts (for different attack reasons) I can't use get component to damage them, how would I fix this because I can't find a way to getcomponent for just a script in general

slender nymph
#

separate the health out to another component and/or use an event

quiet pollen
#

Great idea thank you!

#

Yeah that was really easy, thank you for being smart lol

frosty yarrow
vocal veldt
#

the issue was solved already but thank you

frosty yarrow
teal viper
#

Don't add voids anywhere! You're gonna kill us all!!

It's not voids, it's methods. Void is a return type of a method.

frosty yarrow
slender nymph
#

no it isn't, dlich is right. they are methods. void is a return type for methods

teal viper
vocal veldt
frosty yarrow
vocal veldt
#

i'm new to unity so yes

frosty yarrow
#

ok chill out all of you

vocal veldt
#

i understand the logic behind player controllers but i forget exactly how to program them

frosty yarrow
vocal veldt
#

i came from roblox studio so i never had to program movement myself 😭

#

i find c# pretty simple though coming from typescript and lua

#

it's kinda just the engine itself i'm unfamiliar with

teal viper
#

What is there to forget? Query the input, calculate movement vector, then use the CC movement methods or add force/set velocity of an rb.

#

And there are plenty of tutorials that cover that.

vocal veldt
#

yea it's easy to translate that into unity scripts when you're experienced lmao

vocal veldt
#

not everyone immediately memorizes how to program it

teal viper
#

For sure. But you remember the general concept as well as where to look in case you forget(documentation)

vocal veldt
#

i do remember the concept

frosty yarrow
teal viper
#

It's not the same concept. It's a different engine with different implementation and api.

frosty yarrow
teal viper
#

Which is why you need to watch a tutorial.
Or even better an organized course like those on Unity learn.

#

!learn

radiant voidBOT
timber tide
#

you don't actually need to specify return types in godot. It's a dynamic typed language

vocal veldt
#

gdscript or c#

timber tide
#

gdscript ye

#

ah right forgot it has c#. Doesn't work in web still x_x

vocal veldt
#

well they said they used C#

frosty yarrow
# vocal veldt lol

why people start picking on people who used godot before like the engine made good games like buckshot roulette and baking bad

vocal veldt
#

nobody is picking on you

frosty yarrow
teal viper
#

Not picking. Just correcting mistakes and misconceptions to help you grow.

quiet pollen
#

Are we still talking about how they shouldn’t be adding black holes into their project

quiet pollen
#

Nope Im wrong nvm

teal viper
quiet pollen
#

Also I forget how to make character controllers all the time (you brought this up earlier) it got demotivating tbh so I just have decided that whenever I make a new controller I am going to make a copy of that project and make keep it as a template

#

Highly recommend

#

Unless there is a better way to do that

rich adder
woven crater
#

need help i dont know what happen but unity stop giving me error

#

it just pause without giving error . i tried to creating a nullreference error but nothing show

teal viper
woven crater
#

yeah i know about that.
just deleted library folder and obj folder. it seem good now

light cave
#

I don't understand animations and my button got broken smh

#

i only wanted a fadeIn fadeOut animation

#
using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;

public class MainMenu : MonoBehaviour
{
    [SerializeField]
    public Animator animator;
    void Awake()
    {
        animator = GetComponent<Animator>();
    }
    public void GoToScene(string sceneName)
    {
       LoadLevel(sceneName);
    }
    public IEnumerator LoadLevel(string sceneName)
    {
        FadeIn();
        yield return new WaitForSeconds(1.0f);
        SceneManager.LoadScene(sceneName);
        FadeOut();
    }

     public void FadeIn()
    {
        animator.ResetTrigger("End");
        animator.SetTrigger("Start");
    }

    public void FadeOut()
    {
        animator.ResetTrigger("Start");
        animator.SetTrigger("End");
    }
}
grand snow
#

You could just use an bool to do this instead and it would simplify the transitions too

#

Anyway we would need to see the transitions to judge whats wrong

light cave
#

it just that my BUTTON doesn't work

#

like i can't test it

#

the button itself is clickable but it does nothing somehow

#

but i set the function to it

grand snow
#

you have not shared anything that mentions a button

light cave
#

GoToScene is set to the button

grand snow
#

UGUI button?

light cave
#

what is UGUI

grand snow
#

unity gui, the system that uses a canvas

light cave
#

yes yes

#

i use that

grand snow
#

anyway make sure nothing is blocking input to your button and double check your scene has an Event System

light cave
#

chatgpt said

#

i have to use StartCoroutine

#

yes that was the problem

#

lmao

grand snow
#

oh shit, i didnt spot that

#

StartCoroutine(LoadLevel(sceneName));

light cave
#

real

#

i always forget that one

light cave
#

exposed value

#
 public void ApplyMusicSettings()
    {
        string paramName = "Music"; // must match exactly
        if (musicToggle)
        {
            mixer.SetFloat(paramName, 0f);   // 0 dB
        }
        else
        {
            mixer.SetFloat(paramName, -80f); // mute
        }
    }```
#

same name

#

mixer has set

#

im so done man

#

why can't this editor change my exposed variable name to the same as i set it back then? smh

#

no wonder it can't find it

lofty mirage
#

can't you remove the component?

#

and add it back?

light cave
#

i didn't know when i expose something

#

i create a new varible

#

i just had to rename it to match my group name

#

smh

stone narwhal
#

how would you guys learn c# code from start if you had to

#

or currently learning?

umbral wadi
#

I think its rather similar to java

stone narwhal
#

yeah the syntax is rather similar to c#. I know python though ha.

stone narwhal
umbral wadi
#

Through panicking

stone narwhal
#

oh dang

umbral wadi
#

Ive got a game Due tomorrow for a uni assignment

#

Im learning on the fly rn

stone narwhal
umbral wadi
#

Send help

stone narwhal
#

that must be stresssful

umbral wadi
#

I have no idea what im doing

#

Im winging this

stone narwhal
umbral wadi
#

I mean most of my AI is done i just need to do the player

#

This has been written in like 3 days

stone narwhal
#

impressivee

#

see youve got it

umbral wadi
#

My current issue is detecting when the player places a new object the AI should detect if its in range and react accordingly

#

I hope the AI detection from my uni isnt great because im fairly sure half of this is chat gpt

#

My lecturer was useless

#

We werent taught this

umbral wadi
stone narwhal
echo kite
umbral wadi
#

2d game

#

Top down

echo kite
#

and it also works irl

umbral wadi
#

Okay youve lost me slightly

#

How exactly does that work

#

So the Zombies should detect the blue thing ans then stop

#

But the blue thing is placed during runtime

rich adder
#

why not just use an overlapcircle ?

umbral wadi
#

(im learning unity on the fly please explain what that is

#

I am a great student

#

XD

rich adder
#

a circle (in this case) that detects colliders inside of it

umbral wadi
#

Okay

#

That makes sense

#

And then filter that by the tag of the item?

rich adder
#

you can filter by component, tag, layers. Up to you

umbral wadi
#

Okay gimme 10 min ill attempt to code that

echo kite
umbral wadi
rich adder
# umbral wadi like this?

the concept is basically similar, you would need to use the Physics2D. variant, that one is for 3D

umbral wadi
#

oops

#

I do that alot

rich adder
umbral wadi
#

Okey dokes

#

Boi i am really learning on the fly here

rich adder
#

if you're gonna return a transform, that stageTarget assignment is kinda pointless btw

umbral wadi
#

True

rich adder
#

just return either hit.transform or null

umbral wadi
#

Its worked

#

Theyve stopped now to do the rest of it

rich adder
#

btw if you call this frequently you can use

public static int OverlapCircle(Vector2 point, float radius, ContactFilter2D contactFilter, List<Collider2D> results); ```
version
#

depending how often it gets called x how many enemies

#

a filter by layer will also further optimize by not having to scan unnecessary colliders like the enemy itself, walls obstacles or whatever

umbral wadi
#

Im not looking for efficent code XD

#

I just need it to work

#

If this wasnt due tomorrow i would code this better

#

I mean at max theres only going to be 11 objects on screen

#

My leturer never covered like half of this

#

Why am i paiying 9 grand for this degree if you dont teach me what i need to know man ;-;

ionic flax
#

Hey I was using ClientNetworkTransform in unity version 2022.3.9f1 with netcode for gameobjects 1.6.0 and it was working fine, but after updating to 2022.62f2 with netcode for gameobjects 1.12.0 it stopped working, when a server has ownership of the gameobject it moves fine on everyone's end but when the client has ownership it stops moving for all clients except the one that has ownership, does anyone know why?

rich adder
umbral wadi
#

My degree is in robotics, I thought this would be a decent side quest

#

it was not

ionic flax
#

i should ask there?

rich adder
#

yes, wouldn't hurt to also provide the code / setup you have that will help others help you

ionic flax
#

okie, thanks

rich adder
#

newer versions of NetworkTransform now has a dropdown selector for Server / Owner based , idk about your version tho

ionic flax
#

i heard of that, but mine doesnt so :')

umbral wadi
light cave
#

i have the same issue

#

i wanted too much on my project

umbral wadi
light cave
#

today to be uploaded

#

at midnight

umbral wadi
#

Oooof

#

Mines tomorrow at 1pm

#

Any ideas why

#

This works

#

Oh never mind

#

I never call the other function

#

XD

grand snow
#

hmm yes we all understood what you meant /s

umbral wadi
#

you know when youre confused why it doesnt work and you start to type and then you realize

#

Ooops

#

XD

#

Never called the function

grand snow
#

many people here fail to even realise that so you are doing good 👍

umbral wadi
#

We are getting there, Only 5 more thing to implement then my write up ;-;

#

This has been a painful couple of days

vocal veldt
#

i'm trying to make a variable for a ui panel element but it only comes up as a debug element?

#

nvm the panel is an image type i guess

grand snow
#

If its ugui then yes the component used for sprite rendering is Image

umbral wadi
#

Trying to get a sprite to follow the mouse where have i gone wrong

#

yes i know this is a mess

#

Never mind forgot to save the file

#

IT works

#

XD

twin pivot
#

you can use the new input system to just get the cursor position

twin pivot
umbral wadi
#

When you code for too long easy mistakes come frequestly

quiet pollen
#

How am I supposed to make an animation that just goes up and down, I need it for a boss I am working on where he jumps into the air and when he slams down it spawns a spike, but when the animation plays he goes to 0, 0

hot wadi
quiet pollen
#

I tryed to change it a bunch and am now just confused lol

#

also for refrence the boss is lit just a capsule

ruby lion
#

Good evening, I'm having a problem with Unity. This error code appears when I launch a project: "Code execution cannot continue because Unity.dll failed to load. Make sure you meet the system requirements for Unity."

I've tried uninstalling the Unity vrctimes and Unity Hub, restarting, and reinstalling, but the problem persists.
Thanks in advance.

midnight tree
#

By animator component

quiet pollen
#

on or off

midnight tree
quiet pollen
#

do I need an avatar

#

cause I dont have one

midnight tree
#

No

quiet pollen
#

is that the issue

#

ok

#

yeah that didnt fix anything

#

do you think it could be an issue with it being navmesh

quiet pollen
#

I figured it out

ancient rampart
#

not entirely sure if this is considered beginner, but I'm not seeing anywhere else that would be more suitable for this

in my game, I have a mode where players have to say a word from a category, I have a lot of predefined categories and words that work for them, but I also want to allow users to use their own categories in private rooms, unfortunately, having them define their own dictionary of words sounds very very unfun and kind of kills the idea of allowing user defined categories, my initial thought to get around this was ai, and while that works, I would like to avoid it if possible, but I can't think of an elegant way of doing it that doesn't result in a lot of bruteforcing or tons and tons of extra work to implement, anyone have any ideas on this?

#

I also need to actually have a system for "valid" answers, since this will be an online game and it does need to actually validate the answers, plus that way there aren't arguments over if a word works or not

solar hill
#

so you want a mechanic where people can create custom categories to use in private rooms but you think creating said catergories will be unfun?

ancient rampart
#

the game is essentially "say a word from the english dictionary that falls under the category"

#

so unless typing in hundreds and hundreds of words is fun

#

yeah, it'd be unfun to manually make the list of words lol

#

so the "creating a category" portion is mainly just choosing something that would be fun

#

like, unity, if you wanna play with a bunch of game dev friends

solar hill
#

this is a more of a design question

#

and less of a code one

ancient rampart
#

hmm I guess

#

I just need to figure out what method to implement something like that would be solid, to get that list of valid words

cosmic dagger
#

This would be easier if they were given multiple choice with the correct word and incorrect words. There are always more than one word that fits, so allowing them to enter their own will add difficulty in creating the system . . .

ancient rampart
#

yeah, but unfortunately it's not supposed to be a quiz game, but more of a memory and endurance game

#

seeing how many you can think of and saying it before your time is up

#

and like, as I mentioned, Ai would work as a sort of "is this a valid word for category?" and then having it respond with Y/n, but that sounds overengineered and a very wasteful when it comes to resources, and it would also slow things down a lot

mental shoal
#

Can I send my game to someone to help me fix a bug with it?

solar hill
#

the entire game? UnityChanHuh