I have read the tutorials and the existing questions on this but am still unable to work out how to get the actor location within an AI task. The GetActorLocation fails due to the behaviour tree not being part of the level (the initial values are never updated); however, given that the majority of AI/path-finding is based around the location of actors in a level, this makes little sense.
I have tried to get the actor itself to update a key in the blackboard using a sequence of casts but this does not work.
What is the method to get dynamic data into the task of a behaviour tree? Most of the examples and videos use static data basic on way points or destinations that are static.
It seems you’re trying to get AI’s blackboard from a Pawn. Unless you manually added a BlackboardComponent to your pawn it doesn’t have one. Get your blackboard straight from the AIController you have. Also, while at it, the Owner Actor you get with Event Receive Execute in BT tasks is also an AIController, unless you do some advanced stuff.
And as a comment: for movement try using BT move tasks, supplied with the engine. When you use them most of the issues get solved for you and you only need to worry about putting your destination into your blackboard.
Well, if the unreal-ai-tutorial says you can use pawn then you can use pawn Just looked at the code and it turns out pawn is a special case, the blackboard is being taken from the controller anyway.
BT has access to actor, for example you’re getting one as Owner Actor in your task’s Event Receive Execute. But yeah, as a general design rule you shouldn’t put data into your Blackboard from inside the BT tasks. You can, but it’s asking for trouble down the line.
I’m not sure what your problem is. I guess it’s that putting data into Blackboard as a response to OnComponentBeginOverlap doesn’t work. Your setup look correctly, so the bug is in the details. Just debug it (like mousing-over pins when debugging a BP shows you current value of that pin). Make sure casts have expected result, and that blackboard component is not None and the BT is being run for your AI.
Thanks; the enum setting did work, was just being reset before the debug printed it out; d’oh.
Really appreciate the help, has really pushed things along
It’s not good for performance, the system is designed that you update variables such as location with a BT Service. You can set a timer on those so it is not happening every tick. The BT Service will update the BlackBoard and the BT Task should use the Blackboard.