Elevators - unity animations vs Vector3.Lerp/Slerp

I recently created a game in which the player can step on a pressure plate to raise a platform and step off to lower it. The idea is to lure an enemy onto the platform and step onto the plate so that you can send it off to another floor.

I already have been using switches to implement door opening mechanics and that worked nicely. The doors open using a vector3.Lerp to update their positions over time. I thought this would also work for the elevator but much to my dismay found that the elevator did not actually pick up the enemy! It simply passed straight through the enemy, leaving it on the same floor as the player.

After googling ways to make elevators in Unity i came across a posting on unity answers that said to use Unity’s keyframe animation tool instead. I did this and much to my astonishment it works! The elevator now scoops up the enemy like I envisioned.

So my question is “why does unity animation succeed in scooping up the enemy while lerping position fails? What makes an animation so different?”

Are you using Character Controllers?
They have support for moving platforms.

No, both the player amd the enemy are rigidbody + boxcollider style characters.

Why not use Character Controllers?

Fair enough question. Because i forgot they exist, and it was for a 48 hour competition. I went with what I know.

But that doesn’t answer the questions I have about what is so different about animations vs lerping positions. I am really curious about this as it would impact the ability to use elevators to move nonplayer objects as well, wouldn’t it?

Maybe have it apply a very small force to colliding rigidbodies to boost them up while its in motion.

Or if they are “on” it calculate the difference in heights, and lock the rigidbody’s y to that of the platform + difference

Well thats’ the thing, these kinds of one-off solutions are what i hope to avoid in the future which is why I hope to understand why things are as they are before trying to work around them any further. If I understand “how unity is thinking” as such I can know the best way to anticipate these kinds of issues as well as other related ones.

So, what is Unity thinking? I still would like to know.

i is because when you use the animation system if you have the “animate physics” variable enabled it will handle collisions, kinematic rigidboies etc. if you use the Transform class to move objects you are ignoring unity’s collision system, you would have to implement your own collision system, which was explained by Warrior1424, if you used the Transform class

I see that response now, thanks Kieran. Warrior1424’s second post hadn’t appeared by the time I was composing my reply. Thanks for the details!