2D game movement/jump issue

Hi, im working on a 2d Platform game, moves and jumps fine, but if i jump and hit a wall for example and the movement key is still pressed, i.e. the object is colliding with the wall and key is still pressed, my object does (not) fall to the ground freely, it slowly drops down, unless i let go of that movement key…

I tried box, capsule colliders, as well as a character controller. And im not using force to move the player, just a simple transform translate function.

Any ideas why this is happening and how it can be fixed.

Thanx in advance

Try using a rigidbody as your player.

My guess is that you are driving your character against a surface and the physics engine is preventing it from falling at full speed. Note you may want to consider using AddForce() or Rigidbody.velocity rather than Transform.Translate() to move your character if your character has a Rigidbody.

One potential solution to your problem would be to disable keys when you are in a collision. I don’t know if that will work given your game play. I would create a boolean and set it true in OnCollisionStay(). After checking it in Update(), I’d set it to false. I’d do it this way rather than use OnCollisionEnter()/OnCollisionExit() since I’ve seen posts were OnCollisionExit() is not always called for every OnCollisionEnter().