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