// Update is called once per frame void Update() { if (target == null) { return; } if (isHomingProjectile && !target.GetAlreadyDead()) { transform.LookAt(GetAimLocation()); } transform.Translate(Vector3.forward * projectileSpeed * Time.deltaTime); }
public bool CanAttack(GameObject combatTarget) { if (combatTarget == null) { return(false); } Health targetToTest = combatTarget.GetComponent <Health>(); return(!targetToTest.GetAlreadyDead()); }
private void Update() { if (!target) { return; } timeSinceLastAttack += Time.deltaTime; if (target.GetAlreadyDead()) { return; } if (!GetIsInRange()) { GetComponent <Mover>().MoveTo(target.transform.position, 1f); } else { GetComponent <Mover>().Cancel(); StartsAttacking(); } }