- Home /
Collision with ground problem (no collision detected)
I have a cube that can move around (orthographic 2D view), but I also want it to be able to jump when grounded, but I just can't get it to work, and I don't know why, as this should be very simple. Keep in mind that I'm pretty new to Unity.
Here is my script:
void Update() { if (Input.GetButtonDown("Jump") && isJumping == false) { isJumping = true; transform.Translate(Vector3.up * JumpSpeed * Time.deltaTime); }
void onCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Ground") { isJumping = false; print("colliding"); } }
void onCollisionExit(Collision collision) { isJumping = true; }
Even though I try to make it print "colliding" while it's in collision, nothing appears in the console. When I test my game, I can only jump once, because the bool isJumping never goes back to false.
Answer by Berenger · Dec 28, 2010 at 11:09 AM
Try "OnCollisionExit" and "OnCollisionEnter" instead "onCollisionExit" and "onCollisionEnter".
When you have a doubt, F1 ;)