I have a 2d game where when my character stands on a physics object that is on the elevator the object will bug and glitch through the floor or just shoot of somewhere random, I feel like this is the elevators fault because when I do it on a normal ground it doesn’t seem to affect it. All collisions are on block all, any suggestions?
I’m assuming you’re using 3D physics and the Character Controller for your player. If you aren’t, then some of the below may still apply, and other parts may not.
What you end up with is known as a “kinematics chain” where the elevator pushes on the object, and the object pushes on the character.
Unfortunately, the Character controller is not particularly physical – it does not partake in the physics solver the way “unattached” objects do.
One thing you can do is detect when the character steps up on an object, and temporarily weld that object to whatever else it’s connected to. In this case, the box would be welded to the elevator once it’s an avatar support. A second after the character steps off the object, you can un-weld and place it back as an individual actor in the world. This of course has some draw-backs, because the object will now not move if there’s some other external force, and you need to build some subsystem/object to keep track of welded objects, and then un-welding them when it’s appropriate.
Another thing you can do is stop using the Character controller, and build your own controller, based on whatever collision shape and physics implementation you want. Attempt to balance the character using torques based on orientation, attempt to move the character by applying forces/impulses, turn towards the right direction with another torque, and apply a modicum of damping on this physical body. When you do it this way, the controller will be more of “a physical object” that gets pushed around and simulated with all the other objects, and may be more stable when interacting with other objects. The draw-back is that, well, it won’t have all of the tuning to “feel good” as specifically a player character in the game – it will feel more like “a physical object.”