private void OnTriggerStay2D(Collider2D c) { if (canAttack && !attackTarget) { attackTarget = c.GetComponentInParent <HumanCell>(); // if target is a human cell and not already targeted if (attackTarget && !attackTarget.targetedBy) { attackTarget.targetedBy = this; if (!instantKill) { attackTarget.GetComponent <OrganismMovement>().SetCanMove(false); } // Set new attackTarget to move towards it if (orgMovement) { orgMovement.SetTarget(attackTarget); } } else { attackTarget = null; } } }
public void ResetTarget() { if (attackTarget) { attackTarget.targetedBy = null; attackTarget.GetComponent <OrganismMovement>().SetCanMove(true); attackTarget = null; if (orgMovement) { orgMovement.SetTarget(null); } } }