Script acts differently since upgrade to Unity 3

I have a script that keeps the player on a moving platform without sliding off. I made it when I had Unity 2.6. It worked perfectly. Here is the code.

var Player : Transform; 
var Elevator : Transform; 

function OnTriggerEnter (other : Collider) {
Player.parent = Elevator; 
}

function OnTriggerExit (other : Collider) {
transform.DetachChildren();
}

Here is the setup. I have a basic cube for an elevator/moving platform as a test. I used the moving platform script from the 2D gameplay tutorial to make it move between two points vertically at a somewhat slow speed. A child of this cube is a GameObject with a box collider trigger component and the above script attached. The trigger hovers just above the cube, not touching anything at any time except the player. The Elevator variable is set to the trigger, the Player variable is, obviously, set to the player. Back when I was using Unity 2.6, everything worked well. If the player was inside the trigger and therefore riding the elevator cube, the player became a child of the trigger, and was able to ride the elevator without slipping off or falling through. When the player left the elevator and was not inside the trigger anymore, the player was detached. I made a sample scene with this script in it and built it, then didn't touch the scene after that. I made a new project, later updated to Unity 3, and then decided to try out the elevator script again. I made the exact same setup in the new project, but there's a problem - the player no longer detaches when exiting the collider. The player remains a child of the trigger, even after exiting it, which then causes the player to fall through the ground as the elevator moves downward. Thinking I had set something up wrong, I opened the old project and scene, which was in working condition last I had used it (I hadn't touched it since the upgrade). Same problem, the player wasn't detached when exiting the elevator. I played the build with the scene as compiled by Unity 2.6, and it worked, the player got off the elevator and was detached. So it seems that the upgrade to Unity 3 caused the script to not work right. I then tried this script, which I found on this answers site:

function OnTriggerEnter (other : Collider) { 
other.transform.parent = gameObject.transform;
} 
function OnTriggerExit (other : Collider) {
 other.transform.parent = null;
}

Same problem. The player would become a child of the trigger upon entering, but wouldn't be detached when exiting. How do I solve this? I'm 14 and I don't know too much about scripting, I'm better with 3D modeling and such, so forgive me if I'm missing something obvious. Thanks!

EDIT: One thing I forgot to mention, I use the free version of Unity, not Pro. Not sure if that makes a difference or not, but I figured I'd say it anyways.

EDIT 2: Forgot one more thing, my character has a character controller attached. I have tried two scripts, the Lerpz tutorial control script, and the enhanced FPS controller from the wiki (both of which use character controllers). The problem occurs no matter which script I use.

EDIT 3: Sorry to keep editing this, but I'm using Unity 3.3.0f4.

EDIT 4: I've made a project/scene that shows the problem. If somebody with Unity 3.3.0 could download and test this to see if I'm not the only one with the problem, that would be great.

EDIT 5: Sorry to bump this again, but this hasn't been solved yet. I've asked on the Unity forums and only got one reply (which didn't work), and from the looks of a few other comments here I'm not the only one with physics-related issues in Unity 3. I submitted a bug report like somebody here suggested, included the sample scene and such, but got no response. Does anybody know what's going on? If I'm not able to get this worked out I'll have to go back to Unity 2.6.1... But as you can't downgrade project folders I would lose all my scenes I've made so far.

Well, I'm not sure, but maybe it's because you attached your player to the trigger itself. Maybe they ignore collisions with childs by default now, can't say for sure, haven't tested it yet. You could try to parent your player to the platform instead of the trigger.

function OnTriggerEnter (other : Collider) { 
    // here i assign the player to the parent of the trigger
    other.transform.parent = gameObject.transform.parent;
} 
function OnTriggerExit (other : Collider) {
    other.transform.parent = null;
}

Hope that helps.

Jamie.

Like Bunny said, great question.

I did use the same exact code:

var Player : Transform; 
var Elevator : Transform; 

function OnTriggerEnter (other : Collider) {
Player.parent = Elevator; 
}

function OnTriggerExit (other : Collider) {
transform.DetachChildren();
}

What I did, and it worked fine for me. Use a FP controller, normal. Add a box collider to an empty game object, and set it as a trigger (Make sure you tick that box). I put the script ON this trigger, and set the player, and set the other thing as the platform... The plane or whatever.

I then pushed play, I walked in to the collider, and I became a child of the platform. So it did work for me.

Here's the scene:

http://www.2shared.com/file/WLMmdZGW/TESTING_OTHERS.html

To open it, just so you know, drag and drop the folder (Main folder) to a place, goto Unity, File, Open Project, and select the whole folder...

Alright, I did a little bypass stuff to get it to work...

var Player : Transform; 
var Elevator : Transform; 

function Update (){
    Player = GameObject.FindWithTag("Player").transform;
    Elevator = GameObject.FindWithTag("Elevator").transform;

    //if(Input.GetKeyDown("g")){
    //  Elevator.transform.DetachChildren();
    //}
}

function OnTriggerEnter (other : Collider) {
    //print("D");
    if(Player.parent != Elevator){
        Player.parent = Elevator; 
    }
}

function OnTriggerExit (other : Collider) {
    //print("HEY");
    Elevator.transform.DetachChildren();
}

You can take out the comments... But this DOES work... Ignore my last answer.

Um, however, to use, you must give the elevator/player tags... You CAN take the tag part out though like this:

var Player : Transform; 
var Elevator : Transform; 

function Update (){
    //Player = GameObject.FindWithTag("Player").transform;
    //Elevator = GameObject.FindWithTag("Elevator").transform;

    //if(Input.GetKeyDown("g")){
    //  Elevator.transform.DetachChildren();
    //}
}

function OnTriggerEnter (other : Collider) {
    //print("D");
    if(Player.parent != Elevator){
        Player.parent = Elevator; 
    }
}

function OnTriggerExit (other : Collider) {
    //print("HEY");
    Elevator.transform.DetachChildren();
}

Hope this helps some =). The print's are for testing. KEEP the if statement in the OnTriggerEnter. For some reason when it's doing that, it doesn't let you do the OnTriggerExit... I think it might have something to do with like, it's a really deep child or something, I don't know that much of how Unity works...

But have fun! =)

I had a problem similar to this awhile back in a 2D platformer I was working on, I ended up just checking if gravity was activated (e.g. jumping or falling) and removing the parent then.

We have some problem too with Unity 3.x We cannot port our game to Android because of the differences among the 1.7 and the 3.x physics