Ah, my first problem with the new Unity!
Until today, I was able to transport my First Person Controller on a platform with scripted movement and even animated movement by parenting the FPC to the platform. The following parenting script is triggered when the FPC walks onto the platform. In this script, the platform is “FirstPMagicCarpet”. The other objects are superfluous to the problem I describe below the code:
function OnTriggerEnter () {
var GO = GameObject.Find("FirstPMagicCarpet");
var GO1 = GameObject.Find("First Person Controller");
var GO2 = GameObject.Find("CubezInner");
var GO3 = GameObject.Find("CubeyReturnInner");
GO.GetComponent("MoveUnParent").enabled = true;
GO1.transform.parent = GO.transform;
GO2.transform.active = false;
GO3.transform.active = false;
}
function OnTriggerExit () {
var GO = GameObject.Find("FirstPMagicCarpet");
var GO1 = GameObject.Find("First Person Controller");
var GO2 = GameObject.Find("CubezInnner");
var GO3 = GameObject.Find("CubeyReturnInner");
GO1.transform.parent = null;
GO.GetComponent("MoveUnParent").enabled = false;
GO2.transform.active = true;
GO3.transform.active = true;
}
(The trigger with this script lies above the platform and is parented to it. )
The problem is that the script still parents the First Person Controller to the platform (I can see it in the editor), but now the character no longer flies along with it. It just falls through as if it weren’t a child of the platform anymore. Has something changed in Unity 2.0 to cause this? Is there another way to allow my character to fly with the platform? Thanks for your help!
Edit: I parented other rigidbodied objects to the platform, and they fly along with it just fine. Only the First Person Controller falls through the platform, whether it’s a child or not.