I am using rigid bodies on my characters, and I have been having some quirky physics issues for a long time. When a character spawns on top of another character, the characters fly in opposite directions as if an explosion occurred, and characters can push other characters, but I don’t want them to be able to, I just want them to block each other like walls.
What can I adjust on these rigid bodies to fix these issues?
Explosions will happen in physics. That’s normal when you teleport something inside of something else. You should look into capping how fast they can move. Something like:
rb.velocity = Vector3.ClampMagnitude(rb.velocity, maximum);
Alternatively, if all your masses are tiny, it’s easy for them to explode outwards. Higher masses resist this behaviour better. But having other as kinematic might work for you too.
The problem with kinematic is that it’s basically useless other than using gravity. Nothing actually gets stopped by a kinematic object, nor can be it stopped by anything. This means people can just walk through walls and other characters.
Bodies with equal mas will still push each other with equal force it seems.
As a hacky solution I’ve locked the Y for for now, which at least doesn’t make the characters fly into the air. However, I’m still unhappy with the amount of force when rigid bodies appear within each other.