I had a mind to destory gameobject (enemy) or More specific whatever health component.
private void Die()
{
if(isDead) { return; }
GetComponent<Animator>().SetTrigger("die");
isDead = true;
---------> Destory(gameObject, timeToShowDyingMethod); //[SerializeField]
---------> Here I would call a method to drop items if desired
----------> ShowDyingMethod(); <— method to drop items or animate or particle effect, or sound effect…
}
Would this approach get me mixed up later in course?
Also I have another question about the CanAttack() procedure
Something about htis simply does NOT look right?
public bool CanAttack(CombatTarget combatTarget)
{
if(combatTarget == null) { return false; }
Health targetToTest = combatTarget.GetComponent();
return targetToTest != null && !targetToTest.IsDead();
}
-----> seems to me we are already going to return false if targetToTest is null…
-----> aren’t we testing twice? once not needed?
Please explain
Thanks