Script: (remember to change class name and bool names)
using UnityEngine;
using System.Collections;
public class DoorDemo : MonoBehaviour {
public bool NearDoorDemo; // Reference to the animator bool to trigger the state.
private Animator anim; // Reference to the animator component.
private GameObject player;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
anim = GetComponent<Animator>();
}
void OnTriggerEnter (Collider other){
anim.SetBool("NearDoorDemo", true);
}
void OnTriggerExit (Collider other){
anim.SetBool("NearDoorDemo", false);
}
}
Feel free to ask me any questions!
No comments:
Post a Comment