Randomizing Actor spawning and help with movement.


I wanted to do something similar to whack a mole, where an object appears and than disappears after a certain time. I was trying to do it with timelines however I can’t seem to make the sphere to move.

I was trying to follow a tutorial where an elevator goes up and down when you press two buttons and try and apply it to making the sphere move up and down. Then once the player presses the sphere it would restart the cycle and then I was hoping for the event to have a randomized location next time it spawns.


Do you want totally random or semi-random locations? In the ‘totally’ random version you could break the ‘Spawn Location’ vector, so you will have 3 floats (X,Y,Z). Add 3 ‘Random Float In Range"’ nodes (if you want your location to be randomized on all axis), define a range for them and plug them into your spawn location float values. This way every time the game spawns that actor, it will use a random float from the range you provided for each axis.

For semi-randomization you might want to add a few target point actors to your level, position them where you want them, and then use a “Get All Actors Of Class” node to get a reference to all of them, and then put them into an array. You can then use that array (full of possible spawn locations) to choose a random element from it (again, using the “get random from range” node, but with integer this time, minimum is 0, maximum is the length of your array-1) and use the location of the array element for the spawn location.

I hope this helps you a bit, if it is confusing, let me know I’ll explain it more but for now I just wanted to give you some ideas to get started with.

For the lerping part: if you want to keep your current setup, you need to make sure that you execute something when the Timeline udates. Currently, there is nothing connected to it, so nothing will happen when it plays. You not missing much tho, you are lerping between your two positions and that gives you a vector value but you don’t do anything with that value. The lerp node will just calculate a value for you but you need to plug that value into a node that moves the actor. Try the ‘Set Actor Location’ node by connecting it to the ‘Update’ pin of the timeline using the lerped position.

You also probably do not want to start the timeline each tick, just once. It is enough to start a timeline by using ‘Play’ no need to do it every frame.