Professional Documents
Culture Documents
Dooropenscript
Dooropenscript
(the tra pdoor in my scene) // and a Boolean which checks if the doop is open. var target : Transform; var doorOpen = false; // The following function activates whenever a collider passes through it's atta ched object( My collider box named "MyCube" in my scene) function OnTriggerEnter(myTrigger:Collider) { // if-statement, is it the character that collided with the object? if(myTrigger.gameObject.name =="character"){ // This next line merely confirms that the trigger was activated Debug.Log("Character Entered Trigger Area"); // Open the door doorOpen = true; } } // This function checks to see if the doorOpen=true as in above, if it is it rot ates my trapdoor to 35 on the X axis function Update(){ if(doorOpen==true){ target.rotation.x=35; } }