So i have 2 door and 2 animation 1 animation is door goes up and 2nd animation door goes down similar like to fnaf and i want to make a code or something that when i click a key door can close and open with animation
this i door code that i use:
using UnityEngine;
public class Door : MonoBehaviour
{
public GameObject DoorLeft;
public GameObject DoorRight;
void Start()
{
DoorLeft.SetActive(false);
DoorRight.SetActive(false);
}
void Update()
{
//All we're doing is toggling the doors. If they're active, we deactivate them; if they're inactive, we activate them
if (Input.GetKeyDown(KeyCode.A))
{
DoorLeft.SetActive(!DoorLeft.activeSelf);
}
else if (Input.GetKeyDown(KeyCode.D))
{
DoorRight.SetActive(!DoorRight.activeSelf);
}
}
}