Only attack if target is not null

This commit is contained in:
Soulaha Balde 2022-04-02 10:01:52 -04:00
parent e50546b061
commit 7af161f29d

View File

@ -29,7 +29,10 @@ public class Entity : MonoBehaviour
protected virtual void Attack(){ protected virtual void Attack(){
// jason: TODO Either have target be Entity instead of transform, or skip Attack when GetComponent<Entity>() is null // jason: TODO Either have target be Entity instead of transform, or skip Attack when GetComponent<Entity>() is null
Entity targetEntity = target.GetComponent<Entity>(); Entity targetEntity = target.GetComponent<Entity>();
bool isTargetAlive = targetEntity.TakeDamage(attackDmg); if(targetEntity != null){
bool isTargetAlive = targetEntity.TakeDamage(attackDmg);
}
} }
protected virtual void SpecialAttack(){ protected virtual void SpecialAttack(){