How to make character follow an array of points (not spline based)?

Hi Guys,

First let me say I’m still learning and I’m using Blueprints.

What I need to do is pass my character an array of vectors and have it travel to each of the points in sequence. I tried to use MoveToLocation in a loop, but move to location doesn’t give me any signal when it ends. I tried to find other nodes off the AI controller that might do this in a synchronous manner but no dice.

This seems like something that should be easy to accomplish but I’m not having much luck. There is probably a better way than movetolocation. What is the best way to make it happen in a blueprint project? Maybe a plugin somewhere provides this function?

Many Thanks,

Hi antsonthetree,

I cannot provide you any screenshots because I’m not on my pc where UE is installed but maybe this helps:

when you having an AI controller already I assume you are also using behavior tree?

You can setup selector nodes with decorators to check if the movement goal has reach and if so move to the next target point?
(maybethis https://docs.unrealengine.com/latest/INT/Engine/AI/BehaviorTrees/NodeReference/Decorators/index.html#reachedmovegoal or built a custom one)

I know this is not very generic. But you can make it more generic by maybe setting some values when the location is reached to use the next target point in your loop.
Just as an idea

I just setup a blueprint that has an array in it with actors you have placed in the scene, or spawned through the blueprint itself. Then you just step through the array and pick the next point once they have reached the other

Do it as Zoltan wrote, but i have small improvement.

Make empty/dummy blueprint, add to it single ARROW pointing up (it will be visible in editor but not in game)
Place those blueprints in level in spots you want as destination.

Then on begin play of your player controller do foreach of that blueprint arrow typ, you get array of all destination points.
And there is go to location function for AI (forgot its name, sorry).

Thanks for the quick replies. I should have added more info…

xhallix - I am not using a behavior tree. I have not even looked at those. I will add that to my research list. Thanks!

Zoltan - That is what I would like to do, but I am not sure how to determine how the actor reaches the point. MoveToLocation does not give me an event or callback to trigger the next move.

Nawrot - These path arrays are created dynamically during runtime. I will not be able to add anything to the map at design time. Additionally this would have the same issue as above. How to determine when I’m at the next position?

Thanks

I wouldn’t add arrows into the scene on their own because then you have no array that holds the order of those arrows so you can’t say which direction to go in etc.

For the tower defence project im building at the moment I have multiple “waypoint” blueprints that I spawn a billboard with a widget on it to move it around, then I can just step through the array with a ++ to move through it in order. Or if I have reached the end of the array I could turn around if I wanted.

You want to use a behavior tree for it. Using the behavior tree you don’t have to do a blueprint for the movement, you just set a task blueprint that will get your next location, then use a blueprint task thats already built which is the “move to” task which just needs a vector location blackboard key. Then once it reaches the point you have designated you can run your next task, which would be to find the next point and go there. There are a lot of benefits to using behavior tree’s. They can be a bit confusing to start with but definitely worth using.

Then spawn those blueprints at runtime.

To determine if you are at destination add small collision boxes, use their overlap event to check if they overlap with player.
Then tell player controller that it is at destination.

You can also add debug to that blueprint: for eg. show/hide bright mesh or turn light etc.

To get array of destinations you find all blueprint of that class, and read their locations.

Debug and having actual object in destination locations really speeds up finding all mistakes in placing them, esp when you want it dynamically generated.