private void Update() { timeSinceLastAttack += Time.deltaTime; if (target == null) { return; } if (target.IsDead()) { return; } bool isInRange = Vector3.Distance(transform.position, target.transform.position) < currentWeapon.value.GetRange(); if (!isInRange) { mover.MoveTo(target.transform.position, 1f); } else { mover.Cancel(); AttackBehaviour(); } }
private void Update() { m_TimeSinceLastAttack += Time.deltaTime; if (m_Target == null || m_Target.IsDead || attackDisabled) { return; } if (CombatTargetChanged(m_Target)) { StopAttack(); } if (!GetIsInRange(m_Target.transform)) { m_Mover.MoveTo(m_Target.transform.position, 1f); m_Stopped = false; } else { if (!m_Stopped) { m_Mover.Cancel(); m_Stopped = true; } AttackBehaviour(); } }
private void Update() { timeSinceLastAttack += Time.deltaTime; if (!target) { return; } // if (target.IsDead()) if (!mover.NavMeshAgent.isStopped) { animator.ResetTrigger("attack"); animator.SetTrigger("stopAttack"); } if (target.IsDead()) { animator.SetTrigger("stopAttack"); return; } if (!GetIsInRange()) { mover.MoveTo(target.transform.position, 1f); } else { mover.Cancel(); AttackBehaviour(); } }
public void Update() { timeSinceLastAttack += Time.deltaTime; if (target == null) { return; } Health targetHealth = target.GetComponent <Health>(); if (targetHealth != null && targetHealth.IsDead) { return; } if (!GetIsInRange()) { _moverComponent.MoveTo(target.transform.position, 1f); } else { _moverComponent.Cancel(); AttackBehaviour(); } }
private void Update() { timeSinceLastAttack += Time.deltaTime; if (target == null) { return; } if (target.IsDead()) { return; } if (!GetIsInRange()) { mover.MoveTo(target.transform.position, 1f ); } else { mover.Cancel(); AttackBehaviour(); } }
private void Update() { timeSinceLastAttack += Time.deltaTime; if (target == null) { return; } if (target.IsDead()) { return; } // ensure there is already a target if (target != null && !IsInRange()) { // move until in weapon range mover.MoveTo(target.transform.position, 1f); } else { // in weapon range, stop moving mover.Cancel(); AttackBehavior(); } }
void AttackBehaviour() { animator.SetTrigger("attack"); moveController.Cancel(); timeSinceLastAttack = 0f; transform.LookAt(target.transform); }
private void Update() { m_timeSinceLastAttack += Time.deltaTime; // No target exists if (m_target == null) { return; } // Target is already dead if (m_target.IsDead) { return; } // Get in range of the target if (m_target != null && !GetIsInRange(m_target.transform, m_currentWeaponConfig.WeaponRange)) { m_mover.MoveTo(m_target.transform.position, 1f); } else { // Attack the target when in range m_mover.Cancel(); AttackBehavior(); } }
private void GettingToTarget() { timeSinceLastAttack += Time.deltaTime; timeFromLastAttack += Time.deltaTime; if (targetHealth == null) { return; } if (targetHealth.IsDead()) { return; } if (Vector3.Distance(transform.position, targetHealth.transform.position) > currentWeaponConfig.Range) { mover.MoveTo(targetHealth.transform.position); } else { mover.Cancel(); AttackBehaviour(); } }
// Update is called once per frame void Update() { //updat Time since last attack m_timeSinceLastAttack += Time.deltaTime; if (m_Target == null) { return; } if (m_Target.GetIsDead()) { return; } bool isInRange = Vector3.Distance(transform.position, m_Target.transform.position) < m_WeaponRange; Mover mover = GetComponent <Mover>(); //move to target if (!isInRange) { mover.MoveTo(m_Target.transform.position); } else { mover.Cancel(); AttackBehavior(); } }
private void Update() { Health health = GetComponent <Health>(); if (health == null || !health.Alive) { return; } timeSinceLastAttack += Time.deltaTime; if (target == null) { return; } if (GetIsInRange()) { mover.Cancel(); transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.LookRotation(target.position - transform.position, Vector3.up), attackRotationSpeed); if (timeSinceLastAttack > currentWeapon.GetTimeBetweenAttacks()) { AttackBehavoiur(); timeSinceLastAttack = 0f; } } else { mover.MoveTo(target.position, 1f); } }
private void Update() { timeSinceLastAttack += Time.deltaTime; /* This script only works after having an attack attackTarget * and this attackTarget is not dead. */ if (!attackTarget || attackTarget.IsDead()) { return; } if (!GetIsInRange()) { /* If character is too far from attackTarget, * it should move to the attackTarget at first. */ mover.MoveTo(attackTarget.transform.position, 1f); } else { // Stop move and do attack behaviour. mover.Cancel(); AttackBehaviour(); } }
private void Update() { timeSinceLastAttack += Time.deltaTime; if (target == null) { return; } if (target.IsDead()) { target = null; return; } if (!GetInRange()) { // we want to move towards it probs mover.MoveTo(target.transform.position); } else { mover.Cancel(); AttackBehavior(); } }
private void Update() { timeSinceLastAttack += Time.deltaTime; if (target == null || target.IsDead()) { return; } if (!currentWeapon.value) { return; } if (Vector3.Distance(transform.position, target.transform.position) > currentWeapon.value.GetWeaponRange()) { moveComponent.MoveTo(target.transform.position); } else { moveComponent.Cancel(); if (timeSinceLastAttack >= timeBetweenAttacks) { AttackBehaviour(); timeSinceLastAttack = 0; } } }
void Update() { _timeSinceLastSawPlayer += Time.deltaTime; _timeSinceLastPatrolled += Time.deltaTime; _timeSinceAggravated += Time.deltaTime; if (_player.IsAlive() && _fighter.enabled && ShouldAttack()) { if (Vector3.Distance(transform.position, _player.transform.position) - _weaponsRange >= Mathf.Epsilon) { _fighter.Attack(_player.gameObject); _mover.SetSpeed(_chaseSpeed); } _timeSinceLastSawPlayer = 0; } else if (_timeSinceLastSawPlayer - _suspicionTime <= Mathf.Epsilon) { _mover.Cancel(); } else { PatrolBehaviour(); } }
private void Update() { timeSinceLastAttack += Time.deltaTime; if (currentTarget == null || currentTarget.IsDead) { return; } if (Vector3.Distance(transform.position, currentTarget.transform.position) > equippedWeaponConfig.Range) { mover.MoveTo(currentTarget.transform.position, 1); } else { mover.Cancel(); AttackBehaviour(); } }
private void Update() { timeSinceLastAttack += Time.deltaTime; if (target && !target.IsDead()) { if (!GetIsRange()) { Vector3 destination = GetDistanceFromTarget(); mover.MoveTo(destination); } else { mover.Cancel(); AttackBehaviour(); } } }
private void Update() { timeSinceLastAttack += Time.deltaTime; if (!target || target.IsDead) { return; } if (Vector3.Distance(transform.position, target.transform.position) <= weaponRange) { AttackBehaviour(); mover.Cancel(); } else { mover.MoveTo(target.transform.position); } }
// Update is called once per frame void Update() { timeSinceLastAttack += Time.deltaTime; if (target == null) { return; } if (GetIsInRange()) { mover.SetDestination(target.transform.position, 1f); } else { mover.Cancel(); AttackBehaviour(); } }
private void MoveToEnemyToAttack() { if (target == null) { return; } if (target.IsDead()) { return; } if (!GetIsInRange(target.transform)) { mover.MoveTo(target.transform.position, 1f); } else { mover.Cancel(); AttackBehaviour(); } }
private void MoveToTheTarget() { if (target == null) { return; } if (target.IsDead()) { return; } if (target != null && !IsInRange(target.transform)) { mover.MoveTo(target.transform.position, 1f); } else { mover.Cancel(); AttackBehaviour(); } }
private void ProcessAttack() { if (GetIsInRange(target.transform)) { mover.Cancel(); AttackBehaviour(); } else { mover.MoveTo(target.transform.position, 1f); } }
private void MoveToAttack() { if (_target == null) { return; } if (!GetIsInRange()) { _mover.MoveTo(_target.transform.position, 1f); } else { _mover.Cancel(); if (_timeSinceLastAttack > _timeBetweenAttacks) { AttackBehaviour(); _timeSinceLastAttack = 0; } } }
private void Update() { timeSinceLastAttack += Time.deltaTime; if (target != null) { mover.MoveTo(target.transform.position, agent, 1); if (TargetIsInWeaponRange()) { mover.Cancel(); AttackBehaviour(); } } }
private void Update() { if (target != null && CanAttack(target.gameObject)) { if (!GetIsInRange()) { mover.MoveTo(target.transform.position, attackSpeedFraction); } else { mover.Cancel(); AttackBehaviour(); } } }
private void Update() { timeSinceLastAttack += Time.deltaTime; bool isInAttack = GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).IsName("Attack"); if (target == null || target.IsDead()) { return; } if (!GetIsInRange(target.transform)) { if (isInAttack) { GetComponent <Animator>().SetTrigger("attackCancel"); } mover.MoveTo(target.transform.position, 1f); } else { mover.Cancel(); AttackBehaviour(); } }
private void Update() { timeSinceLastAttack += Time.deltaTime; //print(timeSinceLastAttack); if (target == null) { return; } if (target.GetComponent <Health>().IsDead()) { return; } if (IsInRange()) { _mover.Cancel(); AttackBehavior(); } else { _mover.MoveTo(target.position, 1f); } }
// Update is called once per frame void Update() { anim.SetFloat("attackSpeed", attackSpeed); timeSinceAttack += Time.deltaTime; // print("timeSinceAttack: " + timeSinceAttack); if (numberOfAttack > maxNumberOfAttack || timeSinceAttack > maxTimeGapBetweenAttacks) { tempMaxNumberOfAttack = 1; numberOfAttack = 0; StopAttack(); } if (target == null) { return; } if (target.IsDead()) { StopAttack(); target = null; return; } // if (!GetIsInRange(target.transform)&&!isAttacking) // { // mover.MoveTo(target.transform.position, 1f); // } // else if (target) if (GetIsInRange(target.transform) && !isAttacking && target) { mover.Cancel(); if (stamina.HasStaminaLeft()) { AttackBehaviour(20f); } } }
void Update() { if (target == null) { return; } if (!CheckIsInRange()) { mover.MoveTo(target.position); } else { mover.Cancel(); } }
void Update() { if (!target) { return; } bool isInRange = Vector3.Distance(target.position, transform.position) <= weaponRange; if (!isInRange) { mover.MoveTo(target.position); } else { mover.Cancel(); } }