Problems with Linecast walking straight


#1

Hi,
I have some troubles. I’m using RecastGraph, but the path will have some errors. As mentioned in the documentation, I tried to use Linecast, as you suggested in the forum, but I do not know why he didnt walk according to the specified path, that is, walking in a straight line, the following is my script,Thanks so much, Aaron.

                var g = AstarPath.active.data.recastGraph;

                bool tks = g.Linecast(transform.position, targetPostion);
                if (tks == true)
                {
                    seeker.pathCallback += OnPathComplete;
                    seeker.StartPath(transform.position,targetPostion, OnPathComplete);
                }
                else
                {
                    ABPath path1 = ABPath.Construct(transform.position, targetPostion);
                    path1.vectorPath.Add(transform.position);
                    path1.vectorPath.Add(targetPostion);
                    var Cs = path1.CompleteState;
                    Cs = PathCompleteState.Complete;
                    OnPathComplete(path1);
                    Ai.destination = targetPostion;
                }


#2

Hi

I’m not really sure what you are doing in that script. It seems like you are using an AIPath script and setting the .destination property, but you are also doing path requests manually…


#4

Hi

Is the linecast working as expected?
Also, is this in a separate script or as a subclass of he AIPath script or something?