Search Unity

PathStatus always return Partial after custom rotation of agent

Discussion in 'Navigation' started by krol21342, Mar 4, 2022.

  1. krol21342

    krol21342

    Joined:
    Jan 12, 2022
    Posts:
    2
    I check PathStatus of the position to see if the agent can reach the point and in the course of testing it always returns Complete, until i start rotating the agent with these code, after that PathStatus always is Partial. I can't understand the reason for this.

    private IEnumerator OnHidePoint()
    {
    while (_agent.enabled == false && _currentHideSpot != null)
    {
    var currentAngles = transform.eulerAngles;
    transform.eulerAngles = new Vector3(currentAngles.x, currentAngles.x, Mathf.LerpAngle(currentAngles.z, 25f, Time.deltaTime));;

    yield return null;
    }
    }

    Code to check status of position
    public NavMeshPathStatus PointStatus(NavMeshAgent agent, Transform spot)
    {
    var path = new NavMeshPath();
    agent.CalculatePath(spot.transform.position, path);
    Debug.Log($"Path status for {spot.gameObject.name} = {path.status}");
    return path.status;
    }
     
  2. krol21342

    krol21342

    Joined:
    Jan 12, 2022
    Posts:
    2
    Probleb is gone when i rebaked navmesh by NuvMeshSurface Component