AI Move to Specific Waypoint

I have this type of AI character that I want to be able to set to move to waypoints I place in the world, but once they’re done doing that, move to a random point.

I know how to set up moving to random points- there are plenty of tutorials for that. My problem is how to do the waypoint thing, especially if there are multiple AI characters in the level and you might want one to go to one specific waypoint and another to go to a different one.

How do I do this with a Blackboard and a Behavior Tree? I made a Task for this since I bet I’ll need a “Go To Specific Waypoint” Task, but have no idea how to set that up or implement it.

You could add an actor (without visible meshes) that would function as a waypoint, you put it where you want the waypoint to be in your level. Then tell the AI to get this waypoint (waypoints in multiple) and move to one of them, you can use their location as a vector in blackboard or the actor itself. If you want to have only an AI move there and all of them you could set a busy/notbusy bool on the waypoint and check that before moving to it.

Also, but this is more advanced, you could start looking into EQS.

I set up a variable on my Character BP that stores waypoint actors I place in the level. I also tried to do the busy/not busy thing, but before I could test that I tried running it and it just completely skips everything and goes to my other branches I already had in my Behavior Tree.
I tested it with a print string and it’s stopping right at the Decorator. It seems the cast to my Character BP from “Owner Actor” out of “Perform Condition Check” isn’t working.

I noticed in other examples they use the “actor” output as if it meant “controller” and cast to the controller. That makes no sense to me. Is it an actor or a controller and if it can be an actor, shouldn’t I be able to cast to a character BP parent that the AI character was made from?

Here’s the BP of the Decorator:

BT’s functions calls for the AI Controller, not directly the Character. This is the hierarchy: AI Controller > Cast to AI Controller Cast > Get Controlled Pawn > Cast to Character.

Another thing, you can store the waypoints directly in the behavior tree.

PS: sorry I didn’t read the function’s name before answering. What you are trying to do there should probably be in a Service and not in a Decorator. A Decorator improves the functionality of the node it is attached, like with this function by checking the return of a condition (hence the name). A Service instead executes at a custom interval, setting blackboard values as needed.

Could you please restate your question? I have a feeling it’s not “AI Move to Specific Waypoint”. If it was - you could just use the Move To default task .

At Nick: A Move To is a task and it would take a waypoint in, but it wouldn’t possibly know which waypoint and it wouldn’t have a waypoint assigned- all that would need to be done elsewhere. If you have an easy solution for this, please let me know. If you’re unclear about what I’m asking: I’m trying to place waypoint actors in the level by hand so I know where they’ll go and plan a route for them to take (it would be nice if they could cycle up and down the list of waypoints, too). I want to do this in behavior tree because they have existing behaviors like combat and looking for random wander points.

Oh, the assigning wasn’t really the focus. I just thought “since i’m here, might as well assign that too” but really I just want to check that a waypoint exists in the character’s array and if it does, then continue with the whole Move To Waypoint system. I read that Decorators are used as almost like a valve- it allows the branch to execute if it returns true and it skips everything if it returns false. If I remove the assigning of the waypoint, would the rest still be valuable as a Decorator? Could you explain more about your thinking on the use of Decorators?

When the code in 111.png gets executed the only thing that will happen is this: Start > Cast (Failed) > Return Node (false). “Owner Actor” is of type AI Controller, this is fundamental to understand.

As for decorators, and behavior trees in general, my suggestion is to follow few turorials (there are plenty by epic games that go very in depth with the system). But, to put simply, with a decorator you add funcionality to a certain node/branch, for example, a decorator with Perform Condition Check could be used to keep analyzing the dead/not dead status of an enemy while you are shooting at him. If dead the Decorator could be set to abort the branch. This way you have a branch that gets a target and shoots at him, and then with the decorator you add the functionality to stop when he is dead. Hope it’s clear.

A waypoint search is something that can be implemented with a Service for example.

I ended up getting it! Took a while, but what I did was like you said for the most part.

For people trying to do this: I used a Service to check if there were waypoints stored in an array on the character, and if there were, set the State variable to “FollowingWaypoints”

Then on the sequence with the waypoint stuff, added a decorator looking for if State was “Following Waypoints”

And finally, everything about going to waypoints was in a custom task (not just a Move To because I wanted to have more control like if it were to go back and forth or not-- all that goes here).

I just finally got the behavior tree to stop spazzing. Feels good and stable :slight_smile: