Nicholas
Nicholas
CC#
Created by Nicholas on 12/17/2024 in #help
Can't assign private variable (Unity)
I figured out I was creating bob in Start() but in another script a method that uses bob was also being called in start, which meant it wasn't created yet. I just needed to assign bob in awake()
32 replies
CC#
Created by Nicholas on 12/17/2024 in #help
Can't assign private variable (Unity)
Okay. I'll have a look. I really appreciate the help though :)
32 replies
CC#
Created by Nicholas on 12/17/2024 in #help
Can't assign private variable (Unity)
No description
32 replies
CC#
Created by Nicholas on 12/17/2024 in #help
Can't assign private variable (Unity)
No description
32 replies
CC#
Created by Nicholas on 12/17/2024 in #help
Can't assign private variable (Unity)
UIOverlay is a MonoBehaviour and also the script is attached to a canvas gameobject in the screen.
32 replies
CC#
Created by Nicholas on 12/17/2024 in #help
Can't assign private variable (Unity)
No description
32 replies
CC#
Created by Nicholas on 12/17/2024 in #help
Can't assign private variable (Unity)
Oh, sorry, it's different, it's refering to this line in the unity editor bob.UpdateTimer(gameTime);
32 replies
CC#
Created by Nicholas on 12/17/2024 in #help
Can't assign private variable (Unity)
Because when I use it, it gives me this error: NullReferenceException: Object reference not set to an instance of an object GameManager.Update () (at Assets/Scripts/GameManager.cs:234)
32 replies
CC#
Created by Nicholas on 12/17/2024 in #help
Can't assign private variable (Unity)
So it should work using bob.UpdateHealth(); etc? as long as I assign it first in start()?
32 replies
CC#
Created by Nicholas on 12/17/2024 in #help
Can't assign private variable (Unity)
https://paste.mod.gg/ceduulfgszbk/0 Sorry about how messy it is, it's a work in progress 😅 The main problem is I'm trying to assign "bob" in start (will be renamed dw) so I can use the assigned value rather than getting the componant every time I need it. It's used every frame in update which to my knowledge is very inefficient.
32 replies
CC#
Created by Nicholas on 12/17/2024 in #help
Can't assign private variable (Unity)
No description
32 replies