So I know how to make a plane solid for general use. In this game I’m making the plane is the controller. You move the sphere (marble) around by tilting the plane. It’s like an old labyrinth game.
The problem I’m facing is when I tilt the plane one way, and then the opposite way the marble goes through the plane as though the plane isn’t there. The sphere has a mesh collider and a Rigidbody, and so does the plane. I’ve tried changing the settings in the Ridgidbody and colliders and nothing seems to change. The colliders all seem to be the right dimentions. If I lower the rotation speed it happens less often, but even then the marble will eventually go through the floor.
Any idea how to fix this either through settings or code?
The sphere should probably have a sphere collider.
Also make sure you are only manipulating the plane via the rigidbody API. Ergo, Rigidbody.MovePosition/Rotation. Moving it via the normal transform API will circumvent all physics.
you MUST use the MovePosition / MoveRotation methods on it
Here’s why:
With Physics (or Physics2D), never manipulate the Transform directly. If you manipulate the Transform directly, you are bypassing the physics system and you can reasonably expect glitching and missed collisions and other physics mayhem.
This means you may not change transform.position, transform.rotation, you may not call transform.Translate(), transform.Rotate() or other such methods, and also transform.localScale is off limits. You also cannot set rigidbody.position or rigidbody.rotation directly. These ALL bypass physics.
Always use the .MovePosition() and .MoveRotation() methods on the Rigidbody (or Rigidbody2D) instance in order to move or rotate things. Doing this keeps the physics system informed about what is going on.
In addition to what everyone else said, I would probably try using a box collider for your plane, instead of the default mesh collider. I think that would work more reliably for a moving object.