Still getting used to Unity, how can i get the type of movement I'm looking for?

Hello! I’m working on a 2D platformer and my main issue right now is trying to build a player movement system that is snappy like directly changing rb.velocity, but can be influenced by outside forces like a system that is built on addForce. Right now the closest I have is a system that revolves around using an addForce in the fixedupdate that checks the speed on the x axis that is being added via addForce and continually halves if it were about to exceed the cap I set which is meant to be the players speed, but this is only partially working and my character randomly goes faster than intended. Any help would be appreciated!

If you check the attached image, and look in the rightmost box, you’ll see an “accelerate or decelerate to speed” recipe. The code is 3D, but you should be able to do similar with 2D method equivalents.

4 Likes

Thank you so much for the detailed chart! The idea makes sense and I’ll definitely try implementing it when I can. Thanks again!

So in 3d Physics we have ForceMode.Acceleration, which we lack in 2d physics. But all it does is multiply force * Ridigbody.mass, which you can do yourself. Doing this will make your forces will a lot more snappy. Though you will often need a ‘slow down’ force as well to make stopping as snappy as starting.

1 Like