At the moment, I have a some gates (RightDoor, LeftDoor) that play an opening animation when you click on the screen, but would like to make it so that you have to click on a button (Trigger) to open the gates. Do I need to use raycast? If so, how would I implement that? I’m quite new to all this!
(I’ve also locked the mouse to the center of the screen already).
Here is the script I’m using:
(This is attached to my button and the button plays a short animation to show that it is pressed)
var opened = false;
function Update()
{
if (Input.GetButtonDown("Fire1"))
{
if(opened == false)
{
gameObject.Find("LeftDoor").GetComponent(Animation).animation.Play("New Animation2");
gameObject.Find("RightDoor").GetComponent(Animation).animation.Play("New Animation");
gameObject.Find("Trigger").GetComponent(Animation).animation.Play("ButtonPress");
opened = true;
}
}
}