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?
asked Nov 30 '17 at 01:36 PM in Blueprint Scripting
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.
answered Nov 30 '17 at 09:45 PM
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).
Follow this question
Once you sign in you will be able to subscribe for any updates here