Adding Friction to a point moving in 3D space.

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

Recommended Posts

I'm sure this is super easy, but I'm not sure exactly what to do. I have a point that has and x, y, and z position and velocity. I need to slow down it's movement with friction, but I can't just lessen each velocity seprately becuase the velocitys aren't equall to each other (that would make one stop before the others... which looks wierd). It seems like I have to combine thier velocities into one or something crazy. Any ideas?

Share on other sites
vector maths

or, exponential decay

x -= x * 0.01f;
y -= y * 0.01f;
z -= z * 0.01f;

Share on other sites
Thanks a blanket oliii! I owe you corn. Wow.... I don't think that's how you spell "owe." Is it? Nah...

Share on other sites
The only problem with oliii's approach is that it's dependent on the time-step. It is applied based on the number of frames that have elapsed. Depending on what you're doing and how you're doing it, you may want it dependent on how much time has elapsed. You'd do that like this:
const DECAY = 0.8x *= pow(DECAY, dt)y *= pow(DECAY, dt)z *= pow(DECAY, dt)
Where dt is the time per frame, and DECAY is what the speed is factored by every "second".

yes.

Share on other sites
Also, depending on what you're simulating the "friction" may vary as the velocity changes :) Atmospheric drag equations have a velocity-squared in there... Very little friction at low speeds, and lots when you go fast.

Share on other sites
His original approach is perfect for my needs. Thanks again.

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 9
• 11
• 9
• 9
• Forum Statistics

• Total Topics
634135
• Total Posts
3015754
×