- Home /
How can I avoid collisions between the same objects?
I'm creating a 2D game. So I have prefab for a player and prefab for enemy. Enemies will be creating dynamically in the game so there can be a 20-30 clones of enemy prefab in the scene. So my problem is that I need to somehow disable collision between enemies(each enemy has its own velocity and faster enemy can go through the enemy which move slowly), but if enemy hit the player game will be finished. How can I realise it?
Answer by Professor Snake · Nov 20, 2013 at 06:59 PM
Create a new layer called "Enemies" and have it be the layer of all your enemy gameobjects. Then take a look at the Physics Layers settings under Edit/Project Settings/Physics, and disable collisions for objects in the Enemies layer with other objects in that same layer.
Answer by slake_it · Oct 17, 2018 at 07:17 AM
https://docs.unity3d.com/ScriptReference/Physics.IgnoreCollision.html
You can tell physics to exactly ignore collision between two specific colliders ( it's very useful )
Answer by flaviusxvii · Nov 20, 2013 at 06:59 PM
http://docs.unity3d.com/Documentation/Components/LayerBasedCollision.html <-- This can help.
Your answer
Follow this Question
Related Questions
One way platform using 2D Colliders? 11 Answers
On Collision sound clip change 1 Answer
Changing a collision during a collision 2 Answers
How to make a rigid body ignore collider 1 Answer
Dynamic collision sound system (c#) 1 Answer