Hi
I have a character that moves via MoveToLocation. The problem I have is if the character moves on a partial path, OnMoveComplete is called immediatly, the character then moves and calls OnMoveComplete when they reach the partial paths end. I want a callback that only gets called when the character has moved on a path and is no longer moving. I don’t see a way to fix this without modifying engine source and want to solve in game code via overrides. Is there a better way to detect that a character is done moving on a path, full or partial.
i think you can check if “Result” has a certain flag like this:
if (Result.HasFlag(FPathFollowingResultFlags::Success))
{
}
I can do a result to see if its a success or a fail but I don’t know WHY it failed, and its behavior is odd in that it then paths successfully to the partial path (returning success). Thus I’m afraid to react to the failure as I may have a legit fail later in the path.
So the behavior from a SINGLE call to MoveToTargetLocation returns two On Completes:
Partial path-> on move complete (fail)
Character paths
On move complete (success or fail).
Expected:
On Partial Path
Character Paths
On move complete (success or fail).
Not sure how to react only when the character is actually done pathing.
that function is going to get called regardless of whether it’s a success or fail or whatever. They’re not going to have a bunch of different functions for each possibility. It’s just one function.
you need to put an if statement (or a switch), then your code will only run when you want it to, like this
if (Result.HasFlag(FPathFollowingResultFlags::Success))
{
}
if (Result.HasFlag(FPathFollowingResultFlags::Blocked))
{
}
here’s all the flags you could look for
namespace FPathFollowingResultFlags
{
typedef uint16 Type;
const Type None = 0;
/** Reached destination (EPathFollowingResult::Success) */
const Type Success = (1 << 0);
/** Movement was blocked (EPathFollowingResult::Blocked) */
const Type Blocked = (1 << 1);
/** Agent is not on path (EPathFollowingResult::OffPath) */
const Type OffPath = (1 << 2);
/** Aborted (EPathFollowingResult::Aborted) */
const Type UserAbort = (1 << 3);
/** Abort details: owner no longer wants to move */
const Type OwnerFinished = (1 << 4);
/** Abort details: path is no longer valid */
const Type InvalidPath = (1 << 5);
/** Abort details: unable to move */
const Type MovementStop = (1 << 6);
/** Abort details: new movement request was received */
const Type NewRequest = (1 << 7);
/** Abort details: blueprint MoveTo function was called */
const Type ForcedScript = (1 << 8);
/** Finish details: never started, agent was already at goal */
const Type AlreadyAtGoal = (1 << 9);
/** Can be used to create project specific reasons */
const Type FirstGameplayFlagShift = 10;
const Type UserAbortFlagMask = ~(Success | Blocked | OffPath);
FString ToString(uint16 Value);
}
Thanks for responding.
I do understand the move to has different returns like “Blocked”. However it will then auto restart pathing if that path was partial. If the path was not partial the AI stops moving. Thus the agent has different behavior based on if the path was partial or not but I have no way to know that the path was partial within this particular callback utilizing those flags , thus I don’t know if the AI will automatically start moving again or not.
I resovled the issue by not allowing movement on partial paths, though I feel like there is probably another way to do this.
there’s a function called StopMovement() that will make the ai controller stop, so you could do this
if (Result.HasFlag(FPathFollowingResultFlags::Blocked))
{
StopMovement();
}
or you could try this. If it’s anything other than successful, stop moving
if (!Result.HasFlag(FPathFollowingResultFlags::Success))
{
StopMovement();
}
thanks I think this is the best solution given the situation though its the same as not allowing partial paths.