Sign in to follow this  

Simple Question: Smooth Movement

This topic is 3842 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

When I have to move something from point A to B in the simplest possible fashion, I will check to see what the current location is compared to point B and move the current position by a constant amount. This leads to very jerky movements that start and stop immediately with no acceleration/deceleration. When I need smoother movements, the only thing I really know how to do right now is have a velocity variable that increases every frame while speeding up, then decreases while slowing down, but if you need something to land on a specific point this technique is quite difficult. I don't know exactly what I'm looking for is called, so I'm having difficulty just doing a Google search. But if anyone can point me in the right direction for how to make that kind of smooth movement, that would be great.

Share this post


Link to post
Share on other sites
First, decide the amount of time, T, you want it to take for the something to get from point A to point B. Then you can compute its current location like this: If the current time is t, compute an interpolation factor, s, like this:
    s = 3(t/T)2 - 2(t/T)3 
... and compute the current location, P, like this:
    P = (1-s)A + sB 


This is a simplified case of a cubic Hermite spline, where the start point is 0, the endpoint is 1 and the two tangents are 0.

Share this post


Link to post
Share on other sites

This topic is 3842 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this