Player object not following moving platform if it's also moving

Scenario: player has character controller, third person controller and rigidbody. Elevator has mesh collider and rigidbody, and it’s moved by lerp animation . When player is on the elevator, it sometimes (quite often) drops off through the elevator floor if the elevator moves up or down, especially if the player also moves while the elevator moves. Why? Another error is that if the elevator goes down, the player isn’t following smoothly.

What I would try is, through script, parent the animated elevator to the player while the player is on and touching the elevator, and unparent when the player jumps or otherwise leaves the elevator.

Actually I’ve already tried that solution, it doesn’t work if player has rigid body. I removed player’s rigid body, and now my temporaryParent.cs-script works.

Hmm, what happens when you child the rigidbody player to the elevator? Is the elevator kinematic or constrained horizontally?

The elevator’s rigidbody is kinematic and unconstrained. If it is parent of the player that has rigidbody, player disappears or drops through floor if it collides with elevator trigger. The same happens even if the elevator doesn’t have rigidbody component. My conclusion is that temporary parenting doesn’t work if collider has rigidbody as a component, at least in this case.

Maybe making the elevator’s collider vertically thicker will help prevent the player from falling through. I haven’t reproduced your scene identically, but I am testing some things and not coming across your fall-through or disappear problem. My rigidbody “player” is able to ride my rigidbody, animated “elevator” smoothly when childed.

Do you have a screenshot of the scene you could share?

I made some more testing on the subject after altering size and position of the triggercollider and noticed that falling/disapperaring appears only if the rigidbody uses gravity. If I uncheck Use gravity in the inspector, the rigidbody works perfectly when childed. I appreciate that you bother to help resolve this issue, Chrisso.

On the other hand, I think the Use Gravity -feature of the rigidbody may not be necessary since ThirdPersonController has Apply Gravity-function. Maybe the falling error is due to double gravity addition.

I had a problem once with parenting the player to an elevator. What would happen is it would work the first time but when I would leave the platform, it would “steal” my players collider so any other time I would step on a moving platform I’d fall through. I could see it happening in the inspector and was very annoying. I think there was some bug in OnTriggerExit. No idea if it’s fixed now or not. The work around I came up with was to have a dummy collider follow my player around that would trigger the parenting. It worked great so I never never bothered to go back and fix it.