- Home /
Question by
DGKN · Jul 10, 2014 at 05:43 PM ·
jumponcollisionenterragdoll
Jump on collision problem
Hi,
I have a ragdoll and I want it to jump when its feet touch the ground like this :
float jumpForce = 100;
void OnCollisionEnter2D(Collision2D col)
{
if(col.gameObject.tag == "Ground")
{
rigidbody2D.velocity = new Vector2 (0, jumpForce);
}
}
The problem occurs when both feet touch the ground, it jumps twice (which is normal because the script is the same for both feet).
I just want one jump :
foot1 touches the ground : JUMP 1x OR foot2 touches the ground : JUMP 1x
if both touch the ground : JUMP 1x
How can I implement that ? It sounds so easy but I can't do it. Thanks.
Comment
Your answer