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?
3 Answers
3Create 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.
You can tell physics to exactly ignore collision between two specific colliders ( it’s very useful )
Unity - Manual: Layer-based collision detection ← This can help.
Thank you so much!
– hakuro