- Home /
Parent script not being executed or being ignored
I have a class UserPlayer, which is defined
public class UserPlayer : Player {
In Player class, I have a few variables like
public Vector3 moveDestination;
public float moveSpeed = 10.0f;
public int movementPerActionPoint = 5;
public int attackRange = 1;
but somehow UserPlayer remembers values from older iterations and the values don't change if I change them in code, for example, when I launch the game, movementPerAcionPoint is equal to 6. Any tips on how to fix this?
Answer by DiegoSLTS · Jun 28, 2015 at 02:21 PM
Is Player a MonoBehaviour? If it has values setup in the inspector, the instance will have those values, not the ones in the script. Unity creates an instance of that component (with the default values you wrote) and then sets all the values from the inspector automatically.
If you want to change values inside the script do it in the Awake or the Start functions.
Oh, I didn't think Inspector overrides my scripts! Thank you very much!