How do I move an actor to a series of target positions randomly?

Hi folks, I was hoping for a bit of advice to do something which I think is simple enough to do, but I don’t have alot of experience using Blueprints.

What I’d like to do is to have an array of positions (a few target nodes would be fine) and move a specified actor to one of the nodes at random. Also I’d like to be able to stay in that position for a random amount of time (with a specified min and max time) before moving again to a different random target.

Can anyone offer an advice on how to do this please?

Many thanks,

Paul

Make timer

https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/UseTimers/Blueprints/

on each timer event pick random item from array and do with it whatever you need, when actor reaches the point use Delay or Timer to set timer again so new position is randomized.

They are stored in an array, so I’d use a random range starting with 0 for minimum, and the length of the array -1. You can then fetch a random index to get a random position. You can then use MoveTo if the actor is an AI. If the actor isn’t an AI, you will need to get your controller to navigate to that position (which is more difficult). Once it moves, use a random range again to get a float for the wait time (the range you want) and feed it into your delay node. After the delay node, call your movement function again.

Another option is using a blueprint Timer with a random time (since you can’t use a delay node within a function).

Thanks for the advice, I understand it in principal but can’t visualise it in BP -

I’ve made an array of target points that I’d like my actor to go to but I can’t get further than that.

The function below includes the random move function within it. It uses an array of positions to move the actor to a new location (defaulting to the actor that this function is in). It also randomly sets a timer and calls RandomMove again after a set amount of time. In your even graph, connect this function to your ‘pressed.’ Once you press your key, the function starts, and it will automatically keep looping.

http://itzra.in/l2ain/share/screenshots/UE4Editor_2017-11-30_18-08-50.png

I can’t get it to loop around - I don’t know where to plug the completed node into

Starting with your loop, place all of those nodes into a function. You can name your something like RandomMove. When you press your button, call that function. After your setactorlocation node, add a SetTimerByFunctionHandle to call the function you created (Random move). You can set this timer to whatever delay you would like (by getting a random range)

You don’t need the loop, you can fetch directly from the array using your random integer and feeding it into the Get node.

Your random integer in range needs to have the min 0 and the max is the length of the array -1

Am I barking up the wrong tree?

So here’s my Function

And here’s my Event Graph - but it only does this once and the sphere dosen’t make more than one move.

Hello, thanks for the BP diagram. How did you make the GET from set actor location to Random integer in range and the array?

Just click and drag the array peg off then type “get”

Thankyou, such a silly question I know. I’ve got lots to learn :slight_smile:

Adjust to your needs https://i.imgur.com/WOAsOwT.png

Works like a charm! Thanks so much Nachtmahr!