Question by 
               NGN · Aug 22, 2015 at 01:33 PM · 
                double jump  
              
 
              Double Jump and Jump both getting executed
Both Jump and Double jump are getting executed, could somebody please help me?
using UnityEngine; using System.Collections;
public class Player : MonoBehaviour {
 public float JumpForce = 5f;
 private bool isJumping = false;
 private bool isJumping2 = false;
 public GameObject PlayerObj;
 public GameObject GroundObj;
 // Use this for initialization
 void Start()
 {
 }
 // Update is called once per frame
 void Update()
 {
     //Jumping Section
     if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButton(0))
     {
         if (isJumping == false)
         {
             PlayerObj.rigidbody2D.velocity = new Vector2(rigidbody2D.velocity.x, 0f);
             PlayerObj.rigidbody2D.AddForce(new Vector2(0f, JumpForce), ForceMode2D.Impulse);
             isJumping = true;
             print("Jump");
         }
         else if (!isJumping2)
         {
             PlayerObj.rigidbody2D.velocity = new Vector2(rigidbody2D.velocity.x, 0f);
             PlayerObj.rigidbody2D.AddForce(new Vector2(0f, JumpForce), ForceMode2D.Impulse);
             isJumping2 = true;
             print("Double Jump");
         }
     }
 }
 //this bit is to check if the object that collided with it has the ground tag
 
 void OnCollisionEnter2D(Collision2D other)
 {
     if (GroundObj.gameObject.CompareTag("Ground"))
     {
         isJumping = false;
         isJumping2 = false;
         print("Ground");
     }
 }
 
               }
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Karolo320 · Aug 22, 2015 at 02:28 PM
Try GetMouseButtonDown, seems like jumps are executed in following frames.
Thanks a lot, really appreciate it :D had been working on that for hours.
Your answer
 
             Follow this Question
Related Questions
Double Jump in Fighting Game,Double Jump with Force 1 Answer
Double Jump Not Working 0 Answers
double jump 0 Answers
Double jump becoming infinite jumps 1 Answer
Player jumping issue 0 Answers