How can I make an object become a child of another object upon entering a trigger and detach upon exiting?
**EDIT : I figured out how to do this and I am going to leave my working script for others to use ;)**
![alt text][1]
[1]: /storage/temp/26049-whatismeanttohappen.png
It should "hook" the corner object and turn around the corner. I have created a script for this but I'm not too sure where to attach it or whether to identify the trigger or the rotating (Parent) object.
Here's my script: **[FIXED]**
var rotator : Transform;
var player : Transform;
function OnTriggerEnter(collider : Collider){
if(collider.tag == "Trig"){
print("Parented");
player.transform.parent = rotator.transform;
}
}
function OnTriggerExit(collider : Collider){
if(collider.tag == "Trig"){
print("Un-Parented");
player.transform.parent = null;
}
}
↧