Reputation: 153
I am making a 2D game. There are 2 characters, that can shoot bullets into each other and walls. I need to detect collisions between bullets and characters, so bullets and characters Rigidbody2D type should be dynamic. I need to prevent characters from pushing each other, but i have no idea, how to do this, without changinh their Rigidbody2D types. Making all them triggers doesn't work, beacause it will make walls passable. Help me please.
Upvotes: 0
Views: 729
Reputation: 2250
The best solution and something you should start getting use to is putting different collider groups onto different layers and then setting which ones can collide with each other in the project settings panel.
Edit -> Project Settings -> Physics2D
The sort of layer setup I think you are looking for
Upvotes: 1
Reputation: 537
Try making the Bullets triggers, then in a component on the Bullet object you can Destroy(gamobject)
or otherwise redirect the bullet in its OnTriggerEnter2D
method.
That would mean walls are impassable, and bullets don't push anything.
Upvotes: 0