I am up-using node canvas for our strategy game. The characters get different graphs assigned by code at certain events.
sometimes characters are destroyed. Probably my code is buggy because it seems like destroyed characters sometimes also get a graph assigned. Then the agent is “null” and for some reason all newly assigned graphs for existing characters are stuck in the first node.
I refactored my code a bit and maybe fixed the problem there (couldn’t reproduce it yet). But I also patched ActionTask.Execute() just to be more safe:
Hmm. Within this same method (Execute), there is this piece of code:
1
2
3
4
5
6
if(!Set(agent,blackboard)){
latch=false;
returnStatus.Failure;
}
The above code, is basically handling the agent null check but also initializes the agent. The reason this piece of code is not at the very top, is so that the checks and initialization only happen when the action is executed initially (and not every time while it is running).
It seems however that in your case, the agent is destroyed while the action in question is Running or paused?
Are you maybe destroying the agent from within an action task, or is destruction happening from some outside piece of code?
Hello again and thanks for the follow up as well as the information.
I will try to reproduce this and I make the required changes to avoid this null reference. (probably implementing your fix as well).
Thank you 🙂