Hello All,
I’ve been trying to use empty GO as trigger to gradually open a door upwards and was doing okay until I wanted the door to stop moving.
I tried using another trigger collider to stop the door when the door enters the new trigger but not getting any luck. below is the script, can anybody tell me what I’m doing wrong?
//Attached script to empty GO and check isTrigger in inspector
var target : Transform; //target is entrancedoor1
//conditinal switch for Update to execute translate
var OnOFF = 0.0;
function OnTriggerEnter ()
{
OnOFF = 1; //turn switch to On
}
function Update()
{
if(OnOFF == 1)
{
target.transform.Translate(Vector3.up*Time.deltaTime);
}
}
In the inspector, if I manually turn the OnOFF to 0, the door stops moving.
I tried adding
if(target.transform.position.y == 3.0) // 3.0 is door height above floor
{
OnOFF = 0;
}
But not doing anything.
Thanks,
Ray