I’m trying to make a door can be trigger by a power switch. But it keeps playing the animation at the start of the level.
This is the script for the door.
public Animation anim;
void Start()
{
anim = GetComponent ();
}
void Update()
{
if(GameVariable.electCount > 1)
{
anim.Play(“FinalDoor”);
}
}
}
This is the script for the trigger.
//player trigger final door
void OnTriggerEnter (Collider other)
{
if (other.tag == “Player”)
{
GameVariable.electCount +=1;
}
}
}
This is a script for variable
public static class GameVariable {
public static int electCount;
}