Syntax for UPathFollowingComponent condition (AI path)

I’m having trouble figuring out how to get the path status result for my AI character’s path, and then using it as a condition. The main class I’m working with is the “UPathFollowingcomponent” class.
For example, in the C++ documentation there is an “Enum” called “EPathFollowingStatus::Type”. With members like idle, waiting, moving, etc…

How can I get which state the AI character is in (on the path I guess), and then use that state in a condition? Here is my code snippet (which does not work currently):


if (AIInstance1->GetPathFollowingComponent() != nullptr)
  {
   UPathFollowingComponent* PFComp = AIInstance1->GetPathFollowingComponent();

   if (PFComp != nullptr)
   {
    EPathFollowingStatus::Type thePathStatus1 = PFComp->GetStatus();

    if (thePathStatus1 == EPathFollowingStatus::Moving)
    {
     useOnce1 = false;
    }
    else
    {
     useOnce1 = true;
    }
   }
  }

The UE4 editor simply crashes when it hits the " if (thePathStatus1 == EPathFollowingStatus::Moving)" condition. What am I doing wrong?

I should add, what I’m aiming for is getting the current path status, seeing if my character is currently “Moving”, and do logic from that condition.

Code looks alright to me. Have you checked the AIInstance1 pointer for null?

Ya I checked it, and it isn’t null, because it find the PathFollowingComponent just fine, and it runs another function as well. So it’s not null. For some reason, it just doesn’t like the “equivalency” condition when I check the EPathFollowingStatus.

I ended up just doing it in Blueprints…which works, but I want to do it in C++ because it’s so much faster, easier, and more control for me. I like coding more than moving nodes around and plugging in wires. :frowning: