How do I detect a collision without affecting the physics?

Hi,

I'm having several GameObjects in my scene, which have the Rigidbody and SphereCollider Components added.

In most cases, they are supposed to collide and affect each other's velocity on impact, just like the standard behaviour. But in some cases, I just want to detect a collision without actually changing the direction or velocity of the involved objects.

I already call the Physics.IgnoreCollision function in OnCollisionEnter, to deactivate the collision detection, but the Objects still give each other at least a little push. How can I prevent that from happening altogether in certain cases?

Sounds like you need to set the collider to act as a Trigger. Read about triggers on this page (about 1/3 the way down):

http://unity3d.com/support/documentation/Manual/Physics.html

And you can hook your script into trigger events using these functions:

An alternate approach (which might better suit your requirements of having some collisions still act as solid objects) might be to record the current values for the rigidbody's .velocity and .angularVelocity in every FixedUpdate to separate variables.

Then, when a collision is detected, re-set these values to the values recorded on the previous frame (and also deactivate the collisions between those two objects, as you're currently doing).