Okay so I’m trying to make this kind of movement system that some FPS games have:
As you can see as I press any of the WASD keys, you’ll notice that the player slowly accelerates and slows down if I let go. If I am currently going forward and suddenly press S, you’ll notice that the player stops immediately then slowly accelerates backwards. Same goes for the remaining directions, you get the point.
I honestly am not sure on how should I do this kind of system. Any ideas on how should I do this? Any sample code to show me? I’d appreciate if you show it below in the replies.
You could take this from real life, when the movement keys are pressed, it doesn’t mean walk but it means accelerate, same with everything else and it’s inverses.
The character has a velocity, you speed up that velocity and speed down depending on directions. Going forwards and backwards is easier in real life than strafing side to side, so stopping faster to go backwards is by nature also velocity being stopped by opposite force.
Basically, player speed is ball, when you move you roll ball in that direction.