From b80f002175daec50df4c20a5c8b753949bed8c03 Mon Sep 17 00:00:00 2001 From: MarcUs7i <96580944+MarcUs7i@users.noreply.github.com> Date: Fri, 11 Oct 2024 08:57:32 +0200 Subject: [PATCH] Fixed ground collision bug Enemy Claudia dies when it isn't on the ground. At one level the collision check wasn't on the ground which led to this bug Bug only occurred in level9 --- Assets/game/enemy/Claudia/Claudia.prefab | 5 +++-- Assets/game/enemy/Claudia/Scripts/Claudia.cs | 9 ++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Assets/game/enemy/Claudia/Claudia.prefab b/Assets/game/enemy/Claudia/Claudia.prefab index d7ad475..b7c2e0e 100644 --- a/Assets/game/enemy/Claudia/Claudia.prefab +++ b/Assets/game/enemy/Claudia/Claudia.prefab @@ -222,6 +222,7 @@ MonoBehaviour: nextWaypointDistance: 3 health: 100 deathEffect: {fileID: 1755349173569476, guid: 3c45864be6a059a4a82a25e285298338, type: 3} + groundCheckCollider: {fileID: 4147001279113351536} --- !u!70 &8918774247366146758 CapsuleCollider2D: m_ObjectHideFlags: 0 @@ -251,6 +252,6 @@ CapsuleCollider2D: m_IsTrigger: 0 m_UsedByEffector: 0 m_UsedByComposite: 0 - m_Offset: {x: -0.062099952, y: -0.9213682} - m_Size: {x: 0.7099047, y: 0.07086252} + m_Offset: {x: -0.062099952, y: -0.92672855} + m_Size: {x: 0.70990473, y: 0.0815834} m_Direction: 1 diff --git a/Assets/game/enemy/Claudia/Scripts/Claudia.cs b/Assets/game/enemy/Claudia/Scripts/Claudia.cs index 21e2574..3d44127 100644 --- a/Assets/game/enemy/Claudia/Scripts/Claudia.cs +++ b/Assets/game/enemy/Claudia/Scripts/Claudia.cs @@ -18,11 +18,13 @@ public class Claudia : MonoBehaviour Rigidbody2D rb; Transform enemyGFX; Animator animator; - Collider2D groundCheckCollider; [Header("Health")] public int health = 100; public GameObject deathEffect; + + [Header("Ground Check")] + public Collider2D groundCheckCollider; bool StopHurting = false; bool StopAttack = false; @@ -34,7 +36,6 @@ public class Claudia : MonoBehaviour { seeker = GetComponent(); rb = GetComponent(); - groundCheckCollider = GetComponent(); animator = GetComponentInChildren(); player = GameObject.FindGameObjectWithTag("Player").transform; @@ -69,7 +70,7 @@ public class Claudia : MonoBehaviour } float distance = Vector2.Distance(transform.position, player.position); - if (Stop == false && InNear == true && StopAttack == false) + if (!Stop && InNear && !StopAttack) { if (path == null) { @@ -117,10 +118,8 @@ public class Claudia : MonoBehaviour // check if the enemy is not on the ground if (!IsOnGround()) { - // destroy the enemy game object DestroyEnemy(); } - } void OnCollisionEnter2D(Collision2D collision)