Advertisement Jump to content
Sign in to follow this  

Lerping Jitter

This topic is 666 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been stuck all day on this unfortunately. 

Problem in action:

I'm basically simulating a 10/second positional update from the server: It updates the new_pos Vector2 with x, y values 10 times a second. Game is running at 60 fps and I am trying to interpolate the character movement.

And, the lerping code:

	if new_pos.x:
		var lerpspeed = 0.5
		set_pos(Vector2(lerp(get_pos().x, new_pos.x, lerpspeed), get_pos().y))

I'm using the Godot engine by the way (GDScript language)

I've been searching these forums and read that my lerpspeed somehow needs to be dynamic and clamped between 0.1 - 1.  I'm just not entirely sure how to go about doing that. Thanks in advance

Edited by Webzen

Share this post

Link to post
Share on other sites

The problem is that lerp gives you a single value, once. You need to make a note of when you receive each position, and lerp between the previous state and the new state, every update, for a chosen timespan, with the interpolation value changing each time accordingly.

This comes up almost every day, and the answer given by hplus0603 in another thread should illustrate this approach:

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!