Solved: See this post.
So, now that I have drag, expressed as:
k1=.09;
k2=.01;
drag=(k1*accAccumX)+
(k2*(accAccumX*Math.abs(accAccumX)));
accAccumX-=drag;
grandVelX=accAccumX;
My objects will reach a maximum velocity and slow down accordingly. However, they don’t slow down appropriately when on the ground. What I need to devise is a friction when the player is on the ground. This way he doesn’t float along until drag is enough to stop him, but rather stops the player quickly when the controls are released. Like in real life, friction will stop you quickly instead of letting you drag on. Then I can change the value when the player is on ice, or sand, or just grass and have the appropriate effect.
I’ve been looking into it and I can’t find exactly what I am looking for.
Possible solutions:
1. increase the drag (or create a new one) when the player is on the ground, although this isn’t necessarily the best way.
2. Create a new variable ‘friction’ and do something like this:
if (player is on ground)
velocity = velocity * friction;
This doesn’t seem right either.
Any thoughts?
-
moldering posted this
blog comments powered by Disqus

![[loading...]](http://www.projectmoldering.com/images/indicator.gif)