Error When Changing External task -

tubbzay

New member
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)

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!
 
Hey,

I can't open the error log still, receiving the same message as above

I imported the 2019.3 Package from the source, It should be noted that the unity version I'm using is 2019.4LTS in case it isn't supported.
 
You'll still get the same error, but it should have line numbers now so I can pinpoint the cause.
 
Apologies for the inconvenience, changed my core logic earlier before receiving your reply, no longer have the error and don't have version control to revert and reproduce the error.
 
Top