Jump to content
  • Advertisement
Sign in to follow this  
lzr

Simple Question: Smooth Movement

This topic is 4058 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!