/// <summary> /// chase target and attack state /// </summary> private void _chase_state() { Vector3 playerPosition = m_Player.transform.position; m_CurrentDest = playerPosition; m_Direction2target = m_CurrentDest - transform.position; m_Direction2target.y = 0.0f; m_Distance2target = m_Direction2target.magnitude; m_Direction2target.Normalize(); _calc_ranges(); if (m_Kooldown) { m_AttackTimer += Time.deltaTime; if (m_AttackTimer >= attackInterval) { m_Kooldown = false; m_AttackTimer = 0.0f; } } m_Move = Vector3.zero; if (!m_InAttackRange) { if (m_Attack_combo_started) { m_Player.attack_end_notify(this, m_CurrentAttackType); } m_Character.animator.SetBool(/*"pAttack1"*/ HashIDs.Attack1Bool, false); m_Attack_combo_started = false; _calculate_path(ref m_Move); m_Character.setMoveMode(TPCharacter.MovingMode.RotateToDirection); if (m_InFightZoneRange) { m_Character.setMoveMode(TPCharacter.MovingMode.Strafe); } } else { if (!takingHit && !m_Blocking) { m_Character.turnTransformToDirection(m_Direction2target); m_BodyLookDir = m_Direction2target; bool playerUnderAttack = m_NPCManager.AnyNpcInCombatInZone(this); // m_NPCManager.AnyNpcAttackingInZone(this); // if (!m_Attack_combo_started && !m_Kooldown && !playerUnderAttack && !m_Player.triggerActive) { m_InCombat = true; m_Character.animator.SetBool(/*"pAttack1"*/ HashIDs.Attack1Bool, true); m_Attack_combo_started = true; } } } if (!m_InAttackRange) { _add_local_avoidance(ref m_Move); #if SMOOTH_MOVEMENT m_Move = getAVG(); #endif m_Move.y = 0.0f; float mag = m_Move.magnitude; float curSpeed = m_Stats.DefaultMoveSpeed; if (mag < 0.25f) { curSpeed = 0.0f; } m_Move.Normalize(); m_Move *= curSpeed; m_BodyLookDir = (m_InFightZoneRange ? m_Direction2target : m_Move); } else { m_Move = Vector3.zero; } if (takingHit || m_Blocking) { m_Move = Vector3.zero; m_BodyLookDir = Vector3.zero; } m_Character.move(m_Move, false, false, false, m_BodyLookDir, Vector3.zero); }