Preventing objects from intersecting with minimal physics

I’ve been working on this problem for a while with little luck. I have a game in which the player controls a spinning box. Its movement controls are entirely handled by C# script to keep them unaffected by physics, and there is supposed to be no gravity in the environment since it’s set in a flying dream. I don’t want to add anything to my objects that will cause them to be affected by any physics except collisions. My test obstacle is a huge rock (a sphere), which I want to remain stationary no matter how much the player pushes against it.

From the combinations I’ve tried, usually the box goes through the rock. Adding a character controller to the player didn’t work. Adding an identically-sized non-kinematic rigidbody as a child to the player (to avoid physics problems) did nothing. Having the rigidbody on the rock allows me to push it around, which I don’t want, and setting constraints on any axis allows the box to intersect it.

My closest success is having a collider on the rock, and a collider and rigidbody on the player box, but while that makes the rock stationary like I want, when I push the box against the rock, the box jitters, and generally floats around strangely. Checking kinematic causes it to pass through the rock. Doing that, then adding a non-kinematic rigidbody to the rock stops the intersection, but allows it to be pushed around by the box.

Does anyone have any ideas about this?

If the rock is an exact sphere, can’t you hard-code the corners of the box to not pass the radius of the rock?

Rigidbody also has a checkbox “Use Gravity.” Did you try unchecking that?

If that doesn’t work, I’d suggest altering your script to move the rocket perhaps via ConstantForce, which should allow collision to work normally.

I tried something new, which seems to solve the problem, although I’m not experienced enough to know if it’s the best way.

I put a kinematic rigidbody (and collider) on the rock, and non-kinematic rigidbody (and collider) on the box, but changed drag and angular drag to infinity. That seems to work.

Would this cause any unforeseen problems, or is this a good way to handle it?