I’m having some trouble accessing an instance variable in an overridden function after setting it in the start function.
The Debug.Log just returns that the level is still 3 inside of Activate_Skill() but it returns 5 inside of the update function. How do I get the same value inside of Activate_Skill()?
I have tried changing the variable to public, and declaring it in the base class, initializing it to 5 in the base class start function etc,
public class SubClass : BaseClass
{
private int level = 3;
private void Start()
{
level = 5;
}
private void Update()
{
Debug.Log("level: " + level);
}
public override void Activate_Skill()
{
Debug.Log("Level: " + level);
}
}
public abstract class BaseClass : MonoBehavior
{
public abstract void Activate_Skill();
}