// 상태 진행.. public void Execute(Enemy_StateManager e) { if (e.SearchTarget()) { e.m_anim.SetBool("ISRUN", true); e.m_navAgent.SetDestination(e.m_player.transform.position); #region Footstep e.m_footstepTimer += Time.deltaTime; if (e.m_footstepTimer > e.m_footstepCycle) { e.m_audioSource.clip = e.m_audioClip[0]; e.m_audioSource.PlayOneShot(e.m_audioSource.clip); AudioClip temp = e.m_audioClip[0]; e.m_audioClip[0] = e.m_audioClip[1]; e.m_audioClip[1] = temp; e.m_footstepTimer = 0f; } #endregion if (e.canAttack()) { e.ChangeState(Enemy_IDLE.Instance); } } else { e.ChangeState(Enemy_IDLE.Instance); } }
// 상태 진행.. public void Execute(Enemy_StateManager e) { if (!e.SearchTarget()) { if (!e.m_navAgent.hasPath) { //랜덤 패트롤링 NavMeshHit hit; Vector3 finalPosition = Vector3.zero; Vector3 randomDirection = Random.insideUnitSphere * 5f; randomDirection += e.gameObject.transform.position; //randomDirection위치에 navMesh가 존재하여 갈 수 있는지 체크 if (NavMesh.SamplePosition(randomDirection, out hit, 1f, 1)) { finalPosition = hit.position; } e.m_anim.SetBool("ISWALK", true); e.m_navAgent.SetDestination(finalPosition); } else { #region Footstep e.m_footstepTimer += Time.deltaTime; if (e.m_footstepTimer > e.m_footstepCycle) { e.m_audioSource.clip = e.m_audioClip[0]; e.m_audioSource.PlayOneShot(e.m_audioSource.clip); AudioClip temp = e.m_audioClip[0]; e.m_audioClip[0] = e.m_audioClip[1]; e.m_audioClip[1] = temp; e.m_footstepTimer = 0f; } #endregion if (e.m_navAgent.remainingDistance <= e.m_navAgent.stoppingDistance) { e.m_navAgent.ResetPath(); e.ChangeState(Enemy_IDLE.Instance); } } } else { e.ChangeState(Enemy_IDLE.Instance); } }
// 상태 진행.. public void Execute(Enemy_StateManager e) { e.m_idleTime += Time.deltaTime; if (e.m_idleTime >= 1.5f) { if (e.SearchTarget()) { if (e.canAttack()) { e.ChangeState(Enemy_ATTACK.Instance); } else { e.ChangeState(Enemy_RUN.Instance); } } else { e.ChangeState(Enemy_PATROL.Instance); } } }
// 상태 진행.. public void Execute(Enemy_StateManager e) { if (e.SearchTarget()) { Vector3 dir = e.m_player.transform.position - e.gameObject.transform.position; e.gameObject.transform.forward = Vector3.Lerp(e.gameObject.transform.forward, new Vector3(dir.x, 0f, dir.z), Time.deltaTime * 3f); //e.m_upperBody.transform.forward = Vector3.Lerp(e.m_upperBody.transform.forward, dir, Time.deltaTime * 3f); //슛포인트도 조정해야함. if (e.canAttack()) { e.m_anim.SetBool("ISATTACK", true); } else { e.m_idleTime = 1f;//빠르게 재추적하도록 유도. e.ChangeState(Enemy_IDLE.Instance); } } else { e.ChangeState(Enemy_IDLE.Instance); } }