Collision in the air after jumping
Hi, I have this script for jumping:
void Update () {
if (Input.GetKeyDown("space") && isJumping == false)
{
isJumping = true;
rb.AddForce(new Vector3(0.0f, 200.0f, 0.0f));
}
//other movement code
}
void OnCollisionStay()
{
isJumping = false;
}
The problem is that it allows me to do a 'double jump' - if I hit space again mid-jump then the object will jump again, but it'll only do this once and won't allow me to add a third or fourth jump to the chain. I would like it to just allow one, single jump.
After adding some print messages to make sure that isJumping is being set correctly and all that, I determined that the problem is that immediately after jumping the object collides with something in the air, allowing a second jump since it triggers the OnCollisionStay method.
I've checked and there are no colliders or anything in the air around my object. Does anyone have any idea of what might be triggering this mid-air collision?
Your answer
Follow this Question
Related Questions
Jump Script not Working JavaScript 1 Answer
How to make the character walk-jump and walk (and resize the collider when crouched) ? 0 Answers
How to convert keyboard inputs to Circle Pad with n3ds 0 Answers
Keep an object perpendicular to the surface it collides with and parallel to the floor 0 Answers
Issues Getting my GameObject to both Move Forward and Jump properly. 0 Answers