Reputation: 409
I have an abstract class:
public abstract class HitableAbstract : MonoBehaviour
{
public float TimeLeft;
public abstract bool OnHit();
}
and a child class who inherits from this class:
public class Target : HitableAbstract
{
bool isHit = false;
public override bool OnHit ()
{
if (!isHit)
{
isHit = true;
return (true);
}
return (false);
}
}
However, after calling the onHit, isHit stays false. Is this some kind of behaviour of abstract classes that i should know of?
On the internet, i can only find 'get's in override methods. no assignments..
Upvotes: 0
Views: 137
Reputation: 21855
You are probably hitting one variable and checking the status of another one with Unity inspector.
The code you posted is right and there is no 'hidden' behavior of abstract classes.
Upvotes: 1