Door Mechanic


using UnityEngine;
public class Sliding_Door_Script : MonoBehaviour
    public GameObject trigger;
    public GameObject leftDoor;
    public GameObject rightDoor;

    Animator leftAnim;
    Animator rightAnim;

    // Start is called before the first frame update
    void Start()
        leftAnim = leftDoor.GetComponent <Animator > ();
        rightAnim = rightDoor.GetComponent <Animator > ();

    void OnTriggerEnter(Collider coll){
        if (coll.gameObject.tag == “OVRPlayerController”) {
           SlideDoors (true);

    void OnTriggerExit(Collider coll)
        if (coll.gameObject.tag == “OVRPlayerController”)
    void SlideDoors(bool state)
        leftAnim.SetBool(“Slide”, state);
        rightAnim.SetBool(“Slide”, state);

    //end o class

I have created Animations and animation controllers for the door mechanic but they seem to be either opening immediately the scene opens, not responding to player controller collider or opening alternately (with different modifications)

Left door Idle
Left door Open
Left door Closed

Right Door Idle
Right Door Open
Right Door Closed