- Home /
 
               Question by 
               AlexReverse · Jul 31, 2018 at 06:08 PM · 
                c#animationscript.jump  
              
 
              Running animation not working and jumping isn't working.
So I was working on a pause menu but when I tried to play the game the player couldn't jump and the running animation wasn't working.
video here : youtube video .
Then I deleted the pause menu script thinking that the problem was there but no change. I checked the animator and I didn't found a problem there neither. Maybe you guys could help me. So this is the player script
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class Player : MonoBehaviour {
     public float maxspeed = 3;
     public float speed = 50f;
     public float jumppower = 500f;
     float size = 0.15f;
 
     public bool grounded;
     public bool canDoubleJump;
 
     private Rigidbody2D rb2d;
     private Animator anim;
    
     
     void Start () {
         
         rb2d = gameObject.GetComponent<Rigidbody2D>();
         anim = gameObject.GetComponent<Animator>();
        
     }
 
     void Update()
     {
 
         anim.SetBool("Grounded", grounded);
         anim.SetFloat("Speed", Mathf.Abs(Input.GetAxis("Horizontal")));
         if (Input.GetAxis("Horizontal") < -0.1f)
         {
             transform.localScale = new Vector3(-size , size , size);
         }
         if (Input.GetAxis("Horizontal") > 0.1f)
         {
             transform.localScale = new Vector3(size, size, size);
 
         }
 
         if (Input.GetButtonDown("Jump"))
         {
             if (grounded)
             {
                 rb2d.AddForce(Vector2.up * jumppower);
                 canDoubleJump = true;
             }
             else
             {
                 if (canDoubleJump)
                 {
                     canDoubleJump = false;
                     rb2d.velocity = new Vector2(rb2d.velocity.x, 0);
                     rb2d.AddForce(Vector2.up * jumppower);
                 }
             }
         }
     }
     void FixedUpdate()
     {
         Vector3 easeVelocity = rb2d.velocity;
         easeVelocity.y = rb2d.velocity.y;
         easeVelocity.z = 0.0f;
         easeVelocity.x *= 0.75f;
         if (grounded)
         {
             rb2d.velocity = easeVelocity;
         }
 
 
         float h = Input.GetAxis("Horizontal");
         
         rb2d.velocity = new Vector2(h * maxspeed, rb2d.velocity.y);
         
         rb2d.AddForce((Vector2.right * speed) * h);
 
         if (rb2d.velocity.x < -maxspeed)
         {
             rb2d.velocity = new Vector2(-maxspeed, rb2d.velocity.y);
         }   
     }
 }
And this is the groundcheck script
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class GroundCheck : MonoBehaviour{
     private Player player;
     private bool isGrounded;
     void Start()
     {
         player = gameObject.GetComponentInParent<Player>();
     }
 
     void OnTriggerEnter2D(Collider2D col)
     {
         
     }
     void OnTriggerStay2D(Collider2D col)
     {
         player.grounded = true;
     }       
     
     void OnTriggerExit2D(Collider2D col)
     {
         player.grounded = false;
     }
 }
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Parameter 'Jump' does not exist 1 Answer
How can ı activate my jump script only at animation 0 Answers
Play Animation several times 0 Answers
Restore game objects after animation 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                