Why is this C# script not letting me access the animator of another door?

So I’ve been trying to animate a hinge door and I’ve been able to make the animations for it, now that I’ve done that, I’m using a collider with a script inside of it to get the door to open but it won’t let me open it nor does it give an error. Here’s the script:

using UnityEngine;
using System.Collections;

public class DoorScript : MonoBehaviour {
    
    bool DoorOpened;
    public Animator DoorAnimator;

    void Start()
    {
        DoorOpened = false;
    }

    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            DoorOpened = true;
            ControlAnimator("Opened", true);
            print("Animator open door");
        }
    }

    void OnTriggerExit(Collider other)
    {
        if (DoorOpened) 
        {
            DoorOpened = false;
            ControlAnimator("Opened", false);
            print("Animator door close");
        }
    }

    void ControlAnimator(string Type,bool value)
    {
        DoorAnimator.SetBool(Type, value);
    }
}

Make sure a rigidbody is attached to the same object that has this script on it.

  • Does the object to which this script is attached have a collider?
  • Marked as “isTrigger”?
  • Does the thing that is entering the trigger also have a collider?
  • And a rigidbody?
  • And is tagged “Player”?