Download

Behaviour tree tries to access destroyed actor

Hello!

When I test my level I get a number of critical errors, saying that a BTT_bluprint tries to access variables in an actor that is pending destruction.

The exact message is this:
Error Cannot access ‘Soldier_C_3’. It is pending kill. Property: ‘K2Node_DynamicCast_AsAICharacter_Grunt’ from node Finish Execute in blueprint BTT_AttackPlayerError Attempt to assign variable through None from node Finish Execute in blueprint BTT_AttackPlayer

Does anyone know how to fix this? Should I somehow destroy the connection from the actor to the AI controller before I destroy the actor, or have I completely misunderstood the problem?

Are you using the blackboard?

The behavior tree tasks should only get their info from the blackboard.

A service can access other data such as info from your soldier, then set it to the Blackboard. Service’s are not run every tick so they better for performance, because tasks need to be very fast and run a lot they look to the BlackBoard. That way the variable won’t go stale and you do not store a ref in the first place, let the service reget the info, if the soldier’s not there it’s not a problem.

Ok, make sense. I did read the reason for using blackboards, but forgot to implement it all the way in practice. Should fix the problem. Thanks a bunch, mikepurvis!