Download

Swipe from one position to another UE4

Hello I would like to know how to move an actor from one position to another with a give time please .

There are a lot of ways of going about doing something like this and, in spite if the apparent simplicity of the task, most of them can get a little bit complicated.

Here is just one example:

First, every time we want to change the position for the actor to move to, we need to execute some code to store a few variables:

Something like that.

Then, we need to move the actor towards the target location every frame. Seams simple, right? Not Quite.

There’s just one little complication: How do we know when to stop moving the actor?
If we don’t know when to stop the actor from moving, it might get to where we want it to go, but it wouldn’t stay there. It would just fly on by…

In this code, all that is done to fix the issue is to, every frame, check if the actor is within a fairly small distance from the target location and, if it is, set the position of the actor to the target location. That way the actor will move to where we want it to and stay there.

This example is far from perfect and it might not be quite the solution you may have had in mind, but I hope I didn’t over-complicate anything and that it helps nonetheless :slightly_smiling_face:

thank you this is exactly what I wanted