Support Forum

AILepr. How to stop an agent at a point? Vector3

Hello everyone.
I mathematically found a point in the agent’s path. Now I want the agent to stop for a short while at this point.

 if (ai2.canMove == true)
                {
                    if (tochkiSf.Count != 0)
                    {
                        if (transform.position == tochkiSf[0]) 
                        ai2.canMove=false;
                    }       
                }

This code does not work. How to stop the agent at least approximately at the desired point?

Intersections of path and sphere This issue is still relevant.

 if (ai2.canMove == true)
                {
                        if (Vector3.Distance(transform.position, spisokSpecTochki[promShcount]) < 0.1f)
                        {
                            ai2.canMove = false;
                            promShcount = promShcount + 1;
                        }
                           
                }

Can this be done in some other way?

Hi

I would recommend setting ai.destination to the point you calculated. That is the most robust method. Other solutions would require you to either stop inaccurately at the point, or modify the AILerp internals.