Stop Rigidbody From Being Pushed By Another But Still Move With Physics

Hi,

What is the “Unity correct” way to move an object with physics but make it unmovable to identical objects in the scene?

For instance, if a character is moved by physics and can move around freely, I want it to treat other characters as immovable objects even though they have similar masses.

Thanks,

You can set the Layer-based collision: Unity - Manual: Layer-based collision detection

Basically, you set a layer for each object and in Edit>ProjectSettings>Physics you set which layer can collide with which one.
If you want that two same objects dont collide. Just make sure same layer isn’t active in the Layer Collision Matrix

So here is the solution I ended up using if it can help anyone else:

D = collider.position - position;

velocity -= normalize(D) * Dot(velocity, D)

It’s not perfect but it gets the job mostly done.
I hope that helps.