- Home /
The question is answered, right answer was accepted
I have this grounded script and it doesn't work
so I have this script but it does not work with my parameter for my player_run and player_jump which grounded parameters. The script works on the player but not on the parameters
using UnityEngine; using System.Collections;
public class PlayerJump : MonoBehaviour { public bool grounded = true; public float jumpPower; private Rigidbody2D myRigidbody;
// Use this for initialization
void Start ()
{
myRigidbody = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update () {
// Do something
if(!grounded && myRigidbody.velocity.y == 0) {
grounded = true;
}
if (Input.GetMouseButtonDown(0) && grounded == true) {
myRigidbody.AddForce(transform.up*jumpPower);
grounded = false;
}
}
void FixedUpdate ()
{
}
}
what do you mean it works on the player but not on the parameters?
it has a public bool that shows me on my player that i'm grounded but it doesn't work with my animator and the other bool values.
Try changing your jumpPower to a really high value like 100 or 200
Take care with what you are doing! Actually the player can also sometimes reach 0 velocity when he is at the highest point of his jump!
Answer by b1gry4n · Sep 02, 2016 at 09:54 AM
You need to set the parameters in the animator.
https://docs.unity3d.com/ScriptReference/Animator.html
https://docs.unity3d.com/ScriptReference/Animator.SetBool.html
public Animator anim;
anim.SetBool("yourbool", true);