My script:
using UnityEngine;
using System.Collections;
public class TriggerElevatorDoors : MonoBehaviour
{
public Animator anim;
bool areDoorsOpen = false;
// Use this for initialization
void Start ()
{
anim = GetComponent<Animator>();
}
// Update is called once per frame
void Update ()
{
}
void OnTriggerEnter(Collider openDoorCollider)
{
Debug.Log ("Elevator door triggered");
if(!areDoorsOpen)
{
// elevatorDoorsController.SetTrigger ("ElevatorDoorTrigger");
anim.SetBool ("isOpen", true);
areDoorsOpen = true;
}
else
{
anim.SetBool ("isOpen", false);
areDoorsOpen = false;
}
}
}
I have a trigger set to open an elevator door. When triggered I get the error:
MissingComponentException: There is no ‘Animator’ attached to the “ElevatorDoorTrigger” game object, but a script is trying to access it. You probably need to add a Aniamtor to the game object “ElevatorDoorTrigger”. Or your script needs to check if the component is attached before using it.
The problem is that the Animator is definitely assigned but when I click play it disappears. I can’t seem to find anyone else having this issue, might be searching for the wrong thing.