250428 TIL

박소희·2025년 4월 28일

Unity_7기

목록 보기
79/94

NPC가 정지할 때 미끄러지듯이 멈추는 현상이 있었는데, 멈출 때 navMeshAgent의 속도를 초기화시켜 해결했다.

    private void Update()
    {
        if (GameManager.Instance.SimulationMode)
        {
            if (!isPause)
            {
                prevAgentStopped = Agent.isStopped;
                prevAnimSpeed = Animator.speed;

                Agent.velocity = Vector3.zero;
                Animator.speed = 0f;
                Agent.isStopped = true;
                isPause = true;
            }
            return;
        }

        if (isPause)
        {
            Agent.isStopped = prevAgentStopped;
            Animator.speed = prevAnimSpeed;
            isPause = false;
        }

        stateMachine?.Update();
    }

0개의 댓글