// Update is called once per frame void Update() { WeaponController selectedAttack = null; if (desperate) { if (closestAlly) { publicFunctions.MoveTowards(gameObject, closestAlly.transform.position, moveSpeed); Vector3 displacement = transform.position - closestAlly.transform.position; if (displacement.sqrMagnitude < 25) { desperate = false; } return; } } if (target != null) { selectedAttack = publicFunctions.AttackFuntcion(weapons, myHealth, Vector3.Distance(transform.position, target.transform.position), lastAttack + attackDelay); if (selectedAttack) { selectedAttack.Attack(); attackDelay = selectedAttack.GetAttackDelay(); lastAttack = Time.time; return; } publicFunctions.MoveTowards(gameObject, target.transform.position, moveSpeed); } }
// Update is called once per frame void Update() { WeaponController selectedAttack = null; if (target != null) { selectedAttack = publicFunctions.AttackFuntcion(weapons, myHealth, Vector3.Distance(transform.position, target.transform.position), lastAttack + attackDelay); if (selectedAttack) { selectedAttack.Attack(); attackDelay = selectedAttack.GetAttackDelay(); lastAttack = Time.time; } } }