Door Slide Mechanic

Thanks to Al for taking time out to look at my Door Slide Mechanism, we now have a working slide door open and close on a trigger.

I think that now I have this, I will be able to use the mechanism for many interactive features in my world. For instance, I have a skeleton that will stand from sitting and play his violin. I will also be able to trigger other things on and off.

This is the code Al wrote as a quick fix – not bad from 200 miles away from his laptop in Falmouth!

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ToggleDoor : MonoBehaviour
{
    [SerializeField]
    private GameObject LeftDoor;

    [SerializeField]
    private GameObject RightDoor;

    private void OnTriggerEnter(Collider other)
    {
        Debug.Log(“OUCH!!!”);
        LeftDoor.GetComponent<Animator>().SetBool(“slide”, true);
        RightDoor.GetComponent<Animator>().SetBool(“slide”, true);
    }

    private void OnTriggerExit(Collider other)
    {
        LeftDoor.GetComponent<Animator>().SetBool(“slide”, false);
        RightDoor.GetComponent<Animator>().SetBool(“slide”, false);
    }


    [ContextMenu(“ToggleDoor”)]
    void Toggle()
    {
       //
        LeftDoor.GetComponent<Animator>().SetBool(“slide”, true);


    }
}

I still need to animate an idle position for each door so that the doors begin closed before being triggered to open followed by a close when exiting the collider…

SORTED!!!!

One very Happy Bunny here tonight 😀