Path Pending returns true on start, even if not searching?

Hi there,

I have modified my code whereas I am using AIPath, AIDestinationSetter, and Seeker classes on my object along with a class I wrote to control everything. Currently I do not try to do anything if the following is active:

if (!m_myAI.pathPending && m_myAI.reachedEndOfPath)

When my game starts, the game logic does not get past this statement even though I have CanSearch=false and the destination set to NULL.

Can you help me with what I am doing wrong? I am trying to get the pathing system to start in an empty state and wait until I either tell the seeker to create a path to a destination, or call one of the other types based on activity (Flee, Random, etc.)

Thanks for all the help so far!

Hi

Do you think you could try logging those variables to the console? As far as I can see in the code the AI shouldn’t be able to search for a path if canSearch is false.

Think I figured it out by logging:

m_myAI.pathPending: False, m_myAI.reachedEndOfPath:False UnityEngine.Debug:Log(Object) VectorXStudios.Animal:CheckSurroundings() (at Assets/Scripts/Animal.cs:148) VectorXStudios.Animal:Update() (at Assets/Scripts/Animal.cs:155)

There never was a path; therefore, m_myAI.reachedEndOfPath should be False right? I had used the code example you provided in another thread and am wondering if it should be altered? Is there a flag to tell you if a path was ever created (in the history of time)?

Hi

Well, that looks perfectly fine. pathPending is false which means it is not calculating a path and reachedEndOfPath is false because it has not reached the end of the path (it doesn’t have a path at all, so it couldn’t have reached the end of it).

You can check if the AI is following a path using the ai.hasPath property.

Hmmm… this is odd… It shows as having a path even though nothing is moving. Any ideas? I looked and CanSearch is off.

m_myAI.pathPending: False, m_myAI.reachedEndOfPath:False, m_myAI.hasPath:True UnityEngine.Debug:Log(Object) VectorXStudios.Animal:CheckSurroundings() (at Assets/Scripts/Animal.cs:148) VectorXStudios.Animal:Update() (at Assets/Scripts/Animal.cs:155)

I figured it out but not sure what is going on. If I set CanMove = false in the Inspector, it all works. For some reason, if CanMove = true even when CanSearch = false, a path to “nowhere” is created.

Huh. That definitely should not be the case. Which version are you using?