like below, if I want to make a conditions "int" Equals to 1, how can I write it in code?
CodePudding user response:
You can do something like this
public class TestScript : MonoBehaviour
{
Animator anim;
int jumpHash = Animator.StringToHash("Jump"); // Enter the Paramater here
int runStateHash = Animator.StringToHash("Base Layer.Run"); // Enter the Paramater here
void Start ()
{
anim = GetComponent<Animator>();
}
void Update ()
{
float move = Input.GetAxis ("Vertical");
anim.SetFloat("Speed", move);
AnimatorStateInfo stateInfo = anim.GetCurrentAnimatorStateInfo(0);
if(Input.GetKeyDown(KeyCode.Space) && stateInfo.nameHash == runStateHash)
{
anim.SetTrigger (jumpHash);
}
}
}