Make a non-kinematic rigidbody behave like a kinematic one?

In one of my projects, I’ve a player vehicle (actually a miniature submarine inside a human body) whose motion is entirely handled by script, without any use of the physics engine. I would like to achieve two things:

  1. I don’t want, under any circumstances, the physics engine to mess with my submarine. I handle the physics for myself, thank you.

  2. For collisions with obstacles, I would like to use OnCollisionEnter and OnCollisionStay rather than OnTriggerEnter and OnTriggerStay, because unlike the latter ones, the former methods allow to retrieve the actual collision points. (Only knowing that the submarine collided, say, with the heart doesn’t help, as the heart is the whole level.)

Unfortunately, the OnCollision… methods are for some obscure reasons only called when the submarine is not kinematic, so I can’t achieve 1) by checking the “Kinematic” checkbox. (Well, there is a “freeze rotation” checkbox, but unfortunately no “freeze position” checkbox.) In other words, if I want to know where a collision occurs, I have to allow the Physics engine to mess with my submarine… :cry: Dura lex, sed lex.

Hence my question: Does anyone know a trick to discourage the Physics engine from moving my submarine, without declaring it as kinematic? Maybe setting the mass to a tiny value, or the drag value to an insane value? Maybe resetting the position of the collider in each Update or FixedUpdate? Or switching “kinematic” on and off at the right moment? Or something else?

Or maybe should I wait for Unity 3? :roll:

you could set gravity to 0 in edit → project settings → physics thus gravity wont mess with your submarine and you can do as you wish

The problem is not gravity, as there is a “use gravirty” checkbox for rigidbodys. The problem is the physics engine changing the position of my object.

However, I think I’ve found a solution: Instead of making the submarine a rigidbody and collider, I create a child object which is rigidbody and collider. This child has a script which does two things:- It resets its local position in every Update() (not FixedUpdate(), this doesn’t work).

  • It forwards occuring collision messages to it’s parent. So the parent isn’t pushed around by physics, and receives the desired collision message from its rigidbody child.

It’s not a pretty solution but it works. However, I find it sad that I have to trick out the physics engine this way, instead of simply making it ignore the object.

http://unity3d.com/support/documentation/Manual/Physics.html (there is a board with all requirements to triggers OnCollision messages and OnTrigger).

Edit : you may try something. Add a Constant Force component to your gameObject, and give it a Force opposite to the gravity. I just tried it with a cube, I looked at the Physics Manager, the gravity was (0, -9.81, 0). I set a constant force of (0, 9.81, 0), it did not fall.

Edit2 : did not read again, sorry. I think the high drag value is the only solution.