Platformer Movement Speed?

Does anyone know how to code a platformer character who can speed up or slow down? Like Mario 3 or Sonic?

I’m trying to get a character to speed up and slow down when changing directions, but it’s super choppy.

Here is some sample code for you! I added some comments to explain everything, but let me know if you have any questions!

2 Likes

Also, this example uses one value for acceleration and friction, but you could theoretically split those values out. It might make sense for friction to be slower than acceleration for some games

2 Likes