Parenting Problem

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.

I also tried the rigidbody character controller script, but to no avail. The FPC still falls through the moving platform. I did a few searches, but couldn’t find anything about transporting the FPC on another object, except for a post about elevators. The solution for that was the rigidbody FPC script, but it’s not working for me. Does anyone else transport their FPC on another object and have a solution to this problem? Thanks!

Not an elegant solution, but wouldn’t this be easily achieved with just code? You’re already detecting when the player climbs onto the platform, so write some code that ensures that the player follows the platform.

Or…wait for the proper answer. :wink:

Thanks, dfvdan, I hadn’t quite thought of it in that way. I was doing something similar when I was using code to parent the FPC to the platform, and it was working pretty well. The FPC would become “unparented” when he’d step off the platform. I also thought of scripting the same movement as the platform into the FPC when it stepped into the trigger. Another thing I’m going to try is to activate and awaken a rigidbody attached to the FPC when it enters the trigger. Thanks for the suggestion.

:sweat_smile: I found the problem: The Character Controller’s skin was too thin (which is why it kept falling through), and the trigger above the platform was badly placed, so the Character Controller kept unparenting itself. I also edited the parenting script, because I misunderstood a scripting alert in Unity 2.0. Now the transport platform works like a dream.