Z
Z
Zefirot2021-07-30 12:44:24
Unity
Zefirot, 2021-07-30 12:44:24

Why do objects sometimes get stuck in navmesh?

I made 2 points A and B at the bottom of the map and at the top, before starting I check the path

public bool GetAccessPath(Vector3 TargetA, Vector3 TargetB){
        bool ret = false;
        MeshAgentPath = new NavMeshPath();
        NavMesh.CalculatePath(TargetA, TargetB, NavMesh.AllAreas, MeshAgentPath);
        if(MeshAgentPath.status == NavMeshPathStatus.PathComplete){
            TargetCell = TargetB;
            MeshAgent = GetComponent<NavMeshAgent>();
            MeshAgent.updateRotation = false;
            MeshAgent.updateUpAxis = false;
            MeshAgent.Warp(TargetA);
            MeshAgent.SetDestination(TargetCell);
            ret = true;
            }
        return ret;
        }

I create an object
++Num;
Obj[Num] = Instantiate(cell) as Cell;
Obj[Num].transform.SetParent(Cells.transform);
Obj[Num].GetComponent<NavMeshAgent>().speed = Speed;
if(!Obj[Num].GetAccessPath(TargetA, TargetB)){ Obj[Num].gameObject.SetActive(false); }

that is, if there is a path, then forward, if not, then the object is turned off, at startup, the speed is also set randomly (0.2-3), in the update it is only checked whether the goal has been reached
if(Vector3.Distance(transform.position, TargetCell) > 0.5f){  .....

Quality =none, Priority =0, Auto braking = false, Ang speed = 120, Acceleration = 8, radius 0.1, height 0.1
Agent => radius = 0.05, height = 1, step height = 0.001, max slope =
45 objects, many fly, some stop in one place and stay there forever ....
most likely something in the agent's settings, but I've already twisted everything in every way, advise how to set it up correctly, I just need them to move from A to B at a monotonous speed ...
It doesn’t reach how to set it up correctly, and why some fly to the target while others stop ....

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question