From 7af161f29df242229844994847e5c3abe8f7fecb Mon Sep 17 00:00:00 2001 From: Soulaha Balde Date: Sat, 2 Apr 2022 10:01:52 -0400 Subject: [PATCH] Only attack if target is not null --- Assets/Scripts/Entity.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/Entity.cs b/Assets/Scripts/Entity.cs index bd6ea0d..cbeff89 100644 --- a/Assets/Scripts/Entity.cs +++ b/Assets/Scripts/Entity.cs @@ -29,7 +29,10 @@ public class Entity : MonoBehaviour protected virtual void Attack(){ // jason: TODO Either have target be Entity instead of transform, or skip Attack when GetComponent() is null Entity targetEntity = target.GetComponent(); - bool isTargetAlive = targetEntity.TakeDamage(attackDmg); + if(targetEntity != null){ + bool isTargetAlive = targetEntity.TakeDamage(attackDmg); + } + } protected virtual void SpecialAttack(){