Rigid body floating the air when I jump at a wall... how do I fix?

Ok I'm using the function OnCollisionStay to check when I'm inconytact with the ground and its working just fine until I jump at a wall. When I do that my character just stays there floating and not falling until I release my move forward key. So I tried using a raycast and that seemed to work but now I cant go up and down stairs. Help please.

  • Use a rigid body based character controller and make your walls a little bouncy.

or

  • Create a collision area around you stairs, that disables you anti-wall jumping logic OnCollisionStay()
  • Create a small waiting period between when the forward direction is applied to your character controller, so you player progressively falls down, do not allow jump unless character controller is on the ground.

The exact details will vary based on the specifics of your game, if you try to be more specific about your raycast logic, and what you are trying to achieve it would help narrow down the correct solution.

You are not saying what you are doing in OnCollisionStay(), but I guess you are just checking for any collision and treat this as grounded. If you tag your ground you can just check if the collision is with the ground or something else (wall, enemy etc.) and only set grounded = true if the you're colliding with the ground.