- Home /
Rigidbody2D without pushing on collision
TLDR; How to stop movement if two Rigidbodies collides?
Also, here's a potato video of the problem: https://gfycat.com/ComposedArcticBetafish
Say I have three objects in a scene:
Player
Enemy
Rock
The player and enemies is moving freely, but the rock is static. So I attached a Rigidbody2D on player and enemy to move them around with script. All of them has a Box Collider 2D.
Now, if I move into an Enemy, I will start to push it (changing its position). I don't want this. I can set the Enemy's mass to something large, but then two enemies can still push eachother. I don't want this. If I try kinematic solutions I've found, but then they can move through the rock.
I want:
Player can not move enemies
Enemies can not move players
Enemies can not move each other
Nothing can move or go through the rock
Enemies can not move through player
Player can not move through enemies
I keep reading that if I'm moving colliders, I should also use Rigidbodies for performance. But I can't see how I get this to work with Rigidbodies.
How do I set it up?