I have a horse and game object. When horse hit game object, the animation called “fall” will be played. In here I have control animation of this horse. I’ve been try to use OnTriggerEnter() but the animation still can’t play. Can you help me?
Regards,
Tio
This is my Script
public float MoveSpeed = 5.0f;
void Update () {
if (Input.GetKey (KeyCode.UpArrow)) {
animation.Play ("run");
transform.position += transform.forward * MoveSpeed * 0.1f;
} else if (Input.GetKey (KeyCode.Space)) {
animation.Play ("jump");
transform.position += transform.forward * MoveSpeed * 0.1f;
} else if (Input.GetKey (KeyCode.RightArrow)) {
animation.Play ("right");
transform.position += transform.right * MoveSpeed * 0.1f;
} else if (Input.GetKey (KeyCode.LeftArrow)) {
animation.Play ("left");
transform.position += Vector3.left * MoveSpeed * 0.1f;
}
}
void onTriggerEnter(Collider kuda){
if (kuda.gameObject.tag == "Player")
animation.Play ("fall");
}