I’ve seen a million people ask this but i still haven’t found a fix.
So, since i’m really new to Unity and C# in general, i wanted to try to make a simple health and damage system, but it doesn’t work because my health variable refuses to change.
On my player i have attached two scripts, HealthBehaviour and PlayerController.
In my player controller, i have movement and also a test key for damaging the player:
And this is my health system:
I’ve already tried multiple things.
In the example above (first thing i tried), i had the variable as public and changed it in the inspector.
Second attempt, i changed it to:
[System.NonSerialized] public int health = 20;
And it still didn’t change upon damage.
What am i doing wrong? Thanks!