Download

Don't Know How To Pass Blackboard Value to the Blueprint

I am still very new to Unreal Engine and I apologies in advance if this is a stupid question, but I seem to have trouble in understanding how to pass values from Blackboard to my blueprint.
My idea is to make my AI run when it sees the player (chase them), but walk when it does not. I have a boolean in my behavior tree which would be set to true if the player is seen.
This is what I have on my AIController, this passes the boolean key to the Tree:
WhenSeeEnemyBlueprint.png
And it seems to work in my behavior Tree; when the player is seen it is true, when it is not seen it is false.
BehaviorTreeBooleanValue.png
So I am trying to get this value from the behavior Tree and set the speed at which my AI walks in the actual AI Character blueprint (not the controller). This is what I am trying to attempt now and does not seem to work:
SetSpeedOfAI.png
It would be awesome if someone could explain me what I am doing wrong! :slight_smile:

I think you need to make SERVICE blueprint, and add it to behavioral tree. In that service you read key value, find owner pawn and send it there.
Generally play a bit with custom nodes for behavioral trees (and EQS later) i find it much cleaner to “offload” some minor tasks into custom nodes.
Much less clutter in pawn blueprint and easier to find, also well written custom nodes (for eg using dispatchers and interfaces) can be reusable in different AI blueprints.

Hi. First thing I see is that the setting for this is called by the “Event Begin Play” event. So, basically, you’re saying to set the “Max Walk Speed” when the game starts - there’s nothing here to indicate that it should ever be set, changed, or updated again. You’d need another event to call the change of speed once you’re AI no longer sees the player. When the AI can no longer see the player → trigger and event → Set Max Walk Speed=50. That would probably be the most efficient way to do it. Another way would be, if you can tell that your AI is correctly “seeing” and “no longer seeing” the player, you would at least need a bool (variable) that can be checked with the “Event Tick” to change the speed. For example, you create a variable (bool) called “Can See”. So, the AI would see the player → set the variable “Can See” to TRUE → If TRUE, set Max Walk Speed=900 → AI can no longer see the player → set “Can See” to FALSE → If FALSE, set Max Walk Speed=50. Again, you’d want this to happen either on an event triggered by the pawn sensing or somehow on the Event Tick checking whether the bool is TRUE or FALSE … probably a “Do Once” node will keep it from always triggering back-and-forth if you use the Event Tick.

Thank you a lot!!! I will look into it!