using UnityEngine; using UnityEngine.AI; public class ChapterQuest_GetItemObj : MonoBehaviour { public Animation m_Animation; public string GetAnim; public NavMeshAgent m_NavMeshAgent; public Transform[] tfs_target; // 이동 μœ„μΉ˜ bool IsGet; float offtime; int moveindex; void Update() { if (offtime > 0f) { offtime -= Time.deltaTime; if (offtime <= 0f) gameObject.SetActive(false); } if (IsGet) return; if (m_NavMeshAgent != null) { m_NavMeshAgent.SetDestination(tfs_target[moveindex].position); if (m_NavMeshAgent.isOnNavMesh && !m_NavMeshAgent.pathPending) if (m_NavMeshAgent.remainingDistance <= m_NavMeshAgent.stoppingDistance) if (!m_NavMeshAgent.hasPath || m_NavMeshAgent.velocity.sqrMagnitude == 0f) { ++moveindex; if (moveindex == tfs_target.Length) moveindex = 0; } } var dist = Vector3.Distance(MyValue.MyPC.Get_position(), transform.position); if (dist < 2f) { if (m_NavMeshAgent != null) m_NavMeshAgent.isStopped = true; IsGet = true; if (m_Animation != null && !string.IsNullOrEmpty(GetAnim)) { m_Animation.Play(GetAnim); offtime = m_Animation[GetAnim].length; } else offtime = 1f; //GameUI.Ins.IngameUI.m_ChapterQuest.Add_PurposeCount(new ChapterQuestAddData { purpose = ePurpose.GetItem }); } } }