Preventing Rigidbody characters from pushing eachother

I’m building a game which consists of a lot of characters which can push objects around and be pushed around by objects in the environment (and forces applied via code), they all consist of a non kinematic rigidbody and collider and it works fine for the environmental collisions, however i don’t want the characters to be able to push eachother i want them to treat eachother like two character controllers colliding.

So my question basically, is there a simple way of telling the physics engine not to apply force to a character when another character runs into it, or alternatively a way to apply a counter force so that both units hold their ground?

Solved nevermind :slight_smile: just doing a sweeptest eachframe now and applying an equal opposite velocity if a collision is going to occur between characters (hopefully this doesn’t have a performance knock on)

Wouldn’t putting the characters on a layer and have that layer ignore collisions with itself work? There is a collision matrix in the physics settings inspector to do that latter part. I suggest this because I have done this in a game I’m working on now; the “enemies” are all specified like this so that they cannot collide with each other but collide with the environment just fine.

I need the characters to still collide so they don’t pass through each other, just didn’t want them being able to push each other around since they are all rigidbodies

Sweeptesting is a pretty expensive operation, especially once you throw it in update.

An easy fix for this would be to set the rigidbodies to kinematic when they collide. Use tags to check if the object you are colliding with is another character. Just remember to set kinematic to false again once they aren’t colliding.

OnCollisionEnter

OnCollisionExit

This is a pretty standard procedure when working with rigidbodies, I’ve used it loads and I see it used a lot in other projects.