I am trying to make a jump function for my test character. Everything in code appears to be fine. I use BoxCast to cast a box in the lower half of the character and check whether it collides with ‘Terrain’ layer. If it does, then a bool “OnGround” is enabled and player is able to jump. However, there is something wrong with it. When a player presses the “Jump” Button (which is space) at the time it lands, it can sort of clip and not be able to jump for a few clicks. It usually applies a force that pushes it up, but in that glitch it sort of does a very short jump and quickly lands not reaching the quarter of the height it is supposed to reach.
I suspect it might be something to do with collision detection.
More Info:
The character object has a box collider and a rigidbody. All rotation is frozen, none of position change is frozen. The collision detection mode is set to “Continuous Speculative”. Mass is 60, No drag or linear drag. No interpolation.
The ground object only has box collider, no rigidbody. It’s Layer is “Terrain”.
The only change done in physics is that gravity is -35 in the Y direction.
The settings for the Jump button in the Input settings:
Here is the code: