Changing Actor variables through behavior tree

Hello,
I’m working on a behavior tree for my AI and I want to create a task to directly changes a float variable that is within my AI character and updates It, Is It possible?

Sure, have you already tried?

Yes, actually I have made a mistake somewhere that causes me to think maybe It’s not possible now that I got your confirmation I’m looking for a way to fix It.

I’m going to assume you’ve already made a Behavior Tree Task for this answer, but if you haven’t then you’ll need to make one for this.

Changing Actor variables is definitely possible! You’ll want to override "Event Receive Execute AI" in your Task in order to get the Pawn that the Behavior Tree is attached to cast-down to its base Pawn class (you’ll also get it’s Controller, but we don’t need it for this example). From there, you cast the pawn input back up to your desired Pawn class (I use BP_Alien for this example, but ideally it should be the class that is using the behavior tree) and then you can access all variables and functions from that class that you have not made private.

Here’s a photo for example:

Note, don’t forget to call Finish Execute once you’re done! Or else you may get unwanted behavior. You can now add your task to your behavior tree and execute as you’d like!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms