• 카테고리

    질문 & 답변
  • 세부 분야

    게임 프로그래밍

  • 해결 여부

    미해결

13분에 NavMeshAgent가 바꾼 부분에서 실행이 안되어 지네여

22.07.21 21:35 작성 조회수 246

0

void UpdateMoving()
    {
        Vector3 dir = _destPos - transform.position;
        if (dir.magnitude < 0.0001f)
        {
            _state = PlayerState.Idle;
        }
        else
        {
            NavMeshAgent nma = gameObject.GetOrAddComponent<NavMeshAgent>();
            float moveDist = Mathf.Clamp(_speed * Time.deltaTime, 0, dir.magnitude);

            nma.Move(dir.normalized * moveDist);
            transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(dir), 20 * Time.deltaTime);
        }

        Animator anim = GetComponent<Animator>();
        anim.SetFloat("speed", _speed);
    }

 

 

"Move" can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.AI.NavMeshAgent:Move (UnityEngine.Vector3)
PlayerController:UpdateMoving () (at Assets/Scrips/Controllers/PlayerController.cs:49)
PlayerController:Update () (at Assets/Scrips/Controllers/PlayerController.cs:72)

 

오류는 이렇게 뜨는데, 비주얼 문법 상에는 문제가 없다고 뜹니다 ㅠ

답변 2

·

답변을 작성해보세요.

0

파란 영역 (Navigation Mesh)가 생성되지 않아 발생한 문제로 보이네요!

0

방금 해결되었습니다.... Bake 한번 눌러주면 되네여...? 사실 왜 해결되었는지 모르겠습니다...