Hey, I know this is asked like thousand times, but can’t figure it out… :(.
there is my script which is on my door objects sensor, and it plays parent objects animation(door hinge) door works great, but when I dublicated door it plays only 1 door animations even if you’re on another door’s sensor.
So, how can I get this script working on multiple doors?
var guiEnable = false;
private var doorOpen = false;
function OnGUI()
{
if (guiEnable)
{
GUI.Label(new Rect(Screen.width/2 - 75, Screen.height - 100, 150, 30),"Press F to open the door");
}
}
function OnTriggerStay(other : Collider){
if (other.gameObject.tag == "Player") {
door=GameObject.Find("sisäovi");
if (Input.GetButtonDown("F"))
{
if (doorOpen ==false)
{
yield WaitForSeconds (0.5);
door.transform.animation.Play("door2 open");
doorOpen = true;
}
else if (doorOpen ==true)
{
yield WaitForSeconds (1);
door.transform.animation.Play("door2 closen");
doorOpen = false;
}
}
guiEnable = true;
}
}
function OnTriggerExit (other : Collider){
if (other.gameObject.tag == "Player")
{
guiEnable = false;
}
}