Since you gave me a polite reply here is a quick rundown on what to do to get better friction:
1 - process the user inputs rotating them in order to create a vector that pushes player relatively to the angle it is looking;
2 - apply your favorite flavor of friction to the velocity of the previous tic;
3 - add the vector generated at step 1 to your current velocity.
It is ESSENTIAL that friction is applied to velocity before you add the player input vector on top otherwise it will just not work.
See this Quake ground movement for reference.
- Code: Select all • Expand view
void QuakeGroundMove()
{
Usercmd cmd = ZMPlayer.cmd;
//Directional inputs
Acceleration.XY = RotateVector((cmd.forwardmove, - cmd.sidemove), Angle);
//Friction
QuakeFriction(MaxGroundSpeed, 6.f);
//Acceleration
QuakeAcceleration((SafeUnit2(Acceleration.XY), 0), MaxGroundSpeed, Pain ? 1.f : 10.f / MoveFactor);
}
You can use ZMovement as a reference for your own code but please do not copy paste blindly.
First of all, what is the point of that.
Second of all, as specified in the main post, ZMovement is not an optimized piece of code cause it has to continuosly juggle all the customization options.
So use it as a reference, put some effort, and come up with your own interpretation.