Hey guys,
I’m the basic Unity noob but have to finish a project for school. It’s a small game level and what I want to do is to enter a house that I built in Maya. Second thing is that you should only be able to open the door when you first activated a lever.
The house is a small cabin with an animation on the door, so it should open when you click the door. The lever also has a small animation that is triggered by clicking on it. Both of it already works with this code:
function Start ()
{
animation.Stop();
}
function Update ()
{
if (Input.GetButtonDown(“Fire1”)) //check to see if the left mouse was pushed.
{
animation.CrossFade ("OpenDoor"); // if pushed play the animation
}
}
So far so good. Now I have this problem: How can I make the animation only play when the lever is already activated (or in other words when that animation has already played) and otherwise it would give some onscreen text like “the door is locked…”
I tried with a boolean now, like leverActivated = true when the animation has played, but I don’t get how I can use that boolean in the script for the door now…
I would very much appreciate your help and sorry if I’m asking dumb questions…