Allo there. I’m having a strange issue when attaching a First Person Controller as a child of another transform, namely an elevator.
The parentTransform is rotated 180 degrees so as soon as the function fires, the First Person Controller rotates around 180 degrees to match it’s new parent’s localspace. Same thing happens in reverse, the FPC flips a 180 when it becomes relative to worldspace again.
The code looks a lil’ something like this:
private var parentTransform : Transform;
function Start () {
parentTransform = transform.parent;
}
function OnTriggerEnter( collided : Collider ) {
if ( collided.gameObject.tag == "Player" )
collided.transform.parent = parentTransform;
}
I know it works like a charm when the parentTransform isn’t rotated, but I’ll need to set up multiple elevator instances, each with their own unique position & rotation.
Thanks!
Edit: Added Photos as visual-aide.