- Home /
 
 
               Question by 
               daiss1608 · May 29, 2015 at 05:32 AM · 
                c#jumpdouble jump  
              
 
              Character Jump Problem!
So I'm new to Unity. I'm trying to make my 2d character jump. The problem is that the character doesn't jump. Also I want to make it double jump but have no idea how. So here is the code:
`using UnityEngine; using System.Collections;
 
               public class Player : MonoBehaviour { public float Speed = 10.0f; public float JumpSpeed = 0.2f;
 
                private Animator p_Animator;
 private Transform p_GroundCheck;
 void Start () {
     p_Animator = GetComponent<Animator> ();        
     p_GroundCheck = transform.FindChild("GroundCheck");
 }
 
 void FixedUpdate () {
     bool isGrounded = Physics2D.OverlapPoint(p_GroundCheck.position);
     if (Input.GetButton ("Jump")) {
         if (isGrounded) {
             GetComponent<Rigidbody2D> ().AddForce (Vector2.up * JumpSpeed, ForceMode2D.Impulse);
             isGrounded = false;
         }
     }
     float hSpeed= Input.GetAxis("Horizontal");
     p_Animator.SetFloat ("Speed", Mathf.Abs (hSpeed));
     if (hSpeed > 0) {
         transform.localScale = new Vector3 (-1, 1, 1);
     } 
     else if (hSpeed < 0) {
         transform.localScale = new Vector3 (1, 1, 1);
     }
     this.GetComponent<Rigidbody2D>().velocity = new Vector2(hSpeed * Speed, this.GetComponent<Rigidbody2D>().velocity.y); 
 }
 }`
  
                
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Booleans are not working 1 Answer
How can I edit this script to double jump? 0 Answers
Jumping through the roof! 1 Answer