Hi There.
I'm getting thrown an issue when transitioning from on external behavior to another. I was wondering if there is something that I am missing to call when exiting a behavior.
The error I am getting is (I Should also mention I am only getting this error message once, and the behaviour executes as expected)
My Code for switching the external behaviour
Was hoping you might have any solutions to this or if there's something I'm doing wrong on my end. Thanks very much in advance!
I'm getting thrown an issue when transitioning from on external behavior to another. I was wondering if there is something that I am missing to call when exiting a behavior.
The error I am getting is (I Should also mention I am only getting this error message once, and the behaviour executes as expected)
Code:
NullReferenceException: Object reference not set to an instance of an object
BehaviorDesigner.Runtime.BehaviorManager.RunParentTask (BehaviorDesigner.Runtime.BehaviorManager+BehaviorTree behaviorTree, System.Int32 taskIndex, System.Int32& stackIndex, BehaviorDesigner.Runtime.Tasks.TaskStatus status) (at <ddb5579d0d23478c9f73ec2f99600079>:0)
My Code for switching the external behaviour
Code:
public void ChangeCurrentState(AIState targetState)
{
aiCurrentStateBehaviourTree.DisableBehavior();
currentState = targetState;
switch (targetState)
{
case AIState.IDLE:
aiCurrentStateBehaviourTree.ExternalBehavior = GetExternalBehaviourBasedOnType(targetState);
aiIKController.DisableIK_Aim();
break;
case AIState.PATROL:
aiCurrentStateBehaviourTree.ExternalBehavior = GetExternalBehaviourBasedOnType(targetState);
aiIKController.DisableIK_Aim();
break;
case AIState.COMBAT:
aiCurrentStateBehaviourTree.ExternalBehavior = GetExternalBehaviourBasedOnType(targetState);
aiIKController.EnableIK_Aim();
break;
case AIState.DUMMY:
aiCurrentStateBehaviourTree.ExternalBehavior = GetExternalBehaviourBasedOnType(targetState);
aiIKController.DisableIK_Aim();
break;
case AIState.SEARCH:
aiCurrentStateBehaviourTree.ExternalBehavior = GetExternalBehaviourBasedOnType(targetState);
aiIKController.DisableIK_Aim();
break;
}
aiCurrentStateBehaviourTree.EnableBehavior();
}
Was hoping you might have any solutions to this or if there's something I'm doing wrong on my end. Thanks very much in advance!