Need help with RigidBody2D

So I’m making a 2D top-down shooter. You have a rigid body and can move around, and the enemies have rigidbodies and can move around. In order to make them move around I use a custom script which in short moves rigidbody2d.position depending on what buttons you are pressing. Now, the problem is when you walk into one of the enemies they get shoved around. I want them not to shove each other around, but I also don’t want them not to collide at all. Ideally, they would press against each other but not push or pass through the other. I have tried just about everything I can to fix this, so help would be greatly appreciated. Thanks!

If you are just to use 2D RigidBodies, your option is to either having collision enabled or not.
Howver, ther is Body Type
4074655--355132--upload_2019-1-8_5-15-49.png
If you switch to kinematic, then RigidBody wont be pushed, but yes, it will go through.
In conjunction of Kinematic, you should use OnCollisionEnter for example, to detect, when collision exactly happens.

And do your relevant code there.

You can alternatively cheat a little, by forcing velocity to 0 for example.

That’s really good advice, but I do have two questions based on each of your solutions.

  1. If I used kinematic and then used OnCollisionEnter, how would I make pixel perfect collision?
  2. I tried doing what you said by forcing velocity to 0, but it did nothing. I put a script on the enemy object that would set the velocity to Vector3.zero every Update, and also i tried using FixedUpdate and LateUpdate but to no avail. I then watched the rigidbody variables in the editor as I shoved it, and it’s velocity never seemed to rise above 0. Any ideas on how to fix this?

Sorry I forgot, in Kinematic mode, you only control object by script, applying potions, rotations etc.
For pixel perfect, I think you would need write specific own algorithm. Specially if rotation is also involved.
I never had to do so, to be honest.

Alright, thank you so much for your help!