Hello All,
I am trying to create a seek and destroy behaviour. It works fine until the target runs away. Then it throws an NullRefException in the "IsInGunRange" class.
A snippet from IsInGunRange class:
"target" is a SharedGameObject that is returned by "CanSeeObject". Null reference exception throws on the null check line. I don't understand why the sequence won't abort when "CanSeeObject" fails. I tried every kind of conditional aborts.
I am trying to create a seek and destroy behaviour. It works fine until the target runs away. Then it throws an NullRefException in the "IsInGunRange" class.
A snippet from IsInGunRange class:
C#:
public override TaskStatus OnUpdate() {
if (target.Value.transform != null) {
Debug.Log(target.Value.transform);
Transform t = target.Value.transform;
if (Vector3.Distance(t.position, transform.position) < weapon.range) {
return TaskStatus.Success;
}
}
return TaskStatus.Failure;
}
"target" is a SharedGameObject that is returned by "CanSeeObject". Null reference exception throws on the null check line. I don't understand why the sequence won't abort when "CanSeeObject" fails. I tried every kind of conditional aborts.