Lift doors animation problem

Hello,
I am trying to make animation for two lift doors, but it works only in half.
I have two animations for opening and closing doors.

Doors are a child of a trigger. Trigger should work when I will press E button. And it works but only for left doors. Please look at the code and screen.

public class LiftDoorsController : MonoBehaviour
{
    public GameObject ThisTrigger;
   
    [Header("Audio")]
    [SerializeField] private AudioSource doorOpenAudioSource = null;
    [SerializeField] private float openDelay = 0;
    [Space(10)]
    [SerializeField] private AudioSource doorCloseAudioSource = null;
    [SerializeField] private float closeDelay = 0;
   
   
    private void OnTriggerStay(Collider other)
    {
        if(other.tag == "LiftDoor")
        {
            Animator anim = other.GetComponentInChildren<Animator>();
            if(Input.GetKeyDown(KeyCode.E))
            anim.SetTrigger("LiftOpenClose");
            doorOpenAudioSource.PlayDelayed(openDelay);
            print("DoorLiftTrigger");
        }
    }
}

Animator anim = other.GetComponentInChildren<Animator>(); This only get one animator (=> LiftDoors.L). you could use Animator[ ] anims = other.GetComponentsInChildren<Animator>(); to get all animators.

Ok, but it says “(23,13): error CS0103: The name ‘anim’ does not exist in the current context”

  1. anim.SetTrigger(“LiftOpenClose”);

I added
private Animator anim;
and now there is no error but it still doesn’t work.

I mean this:

    private void OnTriggerStay(Collider other)
    {
        if(other.tag == "LiftDoor")
        {
            if (Input.GetKeyDown(KeyCode.E)) {
                // get all animators under door..., but why is the original script getting it from "other"?
                Animator[] anims = other.GetComponentsInChildren<Animator>();
                foreach (Animator anim in anims) {
                    anim.SetTrigger("LiftOpenClose");
                }
                doorOpenAudioSource.PlayDelayed(openDelay);
                print("DoorLiftTrigger");
            }
        }
    }

also there are other details you didn’t show, like “What is the purpose of LiftDoorsController? Are you attaching it on your player, or on the door?”, and “Why is there another script of LiftDoorsControllerR, is it doing something?”.

Yes, the player has also DoorController script.
LiftDoorsControllerR is not in use. I have just created it for a second door, thinking that maybe it will work. But it makes nothing.
LiftDoorsController is only one in use.

After using your suggestion there is no print(“DoorLiftTrigger”); Nothing happens.

Ok, I have it! But thanks to the ChatGPT. After understanding the problem he wrote a different code, which corresponds to both animators.