offsetting character problem, endless temple run-like game

Hi there,

I’m trying to make an endless run game where the character moves forward non-stop, but I want it to be offset to 500 units left/right when player presses D/A.

The offset should take 1 second.

I can not achieve this with timeline for some reason.

The value always ends up more than 500 units.

If I set the animation to take 0.1 seconds, then it goes exactly to 500 units, but it’s a sudden jump and doesn’t look smooth.

Is this achievable with timelines?

I read something about using “FInterp to”, but I just can’t understand how to use this tool.

Thank you.

Put a Clamp right before you set the Current variable. Clamp it to within the limits you need, that way it won’t go past those limits.


Kind of new to this, could please kindly create the connections so I can see?

Sorry, I can’t. On my work laptop, which is incredibly slow to load the UE stuff. The node is named “Clamp”, I believe you would use the Float version of it. Really easy to connect.

You cannot use a timeline for that, it will never move it exactly 500 units because each frame the current value of the time line will be added to the current character’s position. Unless your game runs at a completely fixed framerate, there’s no guarantee this will result in exactly 500 units after 1 second.

You could try always keeping the Actor scene root at the center and move only the character skeletal mesh instead in the local space relative to the scene root. This way you can use a timeline to set its relative location directly instead of adding/subtracting.


This is what I have done, is this what you meant?

This setup makes the character to move to the right constantly with a very high speed and never stops.

That would be because Dis Pressed is True from the moment you press the D key until you turn off the game. You never set it to False.

Also, you’re not checking if the player is already at the maximum it can go. That’s something you’ll want to check after the Branch. Am I already on the right side? If I am, then I can’t go any further to the right.