DasGewehr 9 лет назад
Родитель
Сommit
7b0d6eac41

+ 2 - 2
game/Assets/Prefabs/Bullet.prefab

@@ -22,7 +22,7 @@ GameObject:
   - component: {fileID: 54626927522511238}
   m_Layer: 0
   m_Name: Bullet
-  m_TagString: Untagged
+  m_TagString: Bullet
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
   m_StaticEditorFlags: 0
@@ -40,7 +40,7 @@ GameObject:
   - component: {fileID: 23112293797906142}
   m_Layer: 0
   m_Name: Capsule
-  m_TagString: Untagged
+  m_TagString: Bullet
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
   m_StaticEditorFlags: 0

+ 15 - 0
game/Assets/Scripts/Enemy/Enemy.cs

@@ -10,6 +10,16 @@ public class Enemy : MonoBehaviour
     private PowerLevels powerLevel;
     private EnemyAI.BehaviorController behaviorController;
 
+    void OnCollisionEnter(Collision collision)
+    {
+        Debug.Log("hlk" + collision.collider.tag);
+
+        if (collision.collider.tag == "Bullet")
+        {
+            Death();
+        }
+    }
+
 	// Use this for initialization
 	void Start () 
     {
@@ -29,4 +39,9 @@ public class Enemy : MonoBehaviour
 
         behaviorController.Update();
 	}
+
+    private void Death()
+    {
+        GameObject.Destroy(gameObject);
+    }
 }

+ 2 - 1
game/ProjectSettings/TagManager.asset

@@ -3,7 +3,8 @@
 --- !u!78 &1
 TagManager:
   serializedVersion: 2
-  tags: []
+  tags:
+  - Bullet
   layers:
   - Default
   - TransparentFX