This question was created in reference to: [AI Control rotation [Content removed]
We’re seeing AI using the CrowdFollowing component jittering a bit as they update pathfinding. This is related to the above issue but not the same. The other issue was caused when NOT strafing, this is caused when strafing but moving to a point rather than an actor.
This code:
FVector UPathFollowingComponent::GetMoveFocus(bool bAllowStrafe) const
{
FVector MoveFocus = FVector::ZeroVector;
if (bAllowStrafe && DestinationActor.IsValid())
{
MoveFocus = DestinationActor->GetActorLocation();
}
else
{
const FVector CurrentMoveDirection = GetCurrentDirection();
MoveFocus = *CurrentDestination + (CurrentMoveDirection * FAIConfig::Navigation::FocalPointDistance);
}
return MoveFocus;
}
This fails when pathing is getting updated because GetCurrentDirection reads the value of MoveSegmentDirection, but the CrowdFollowingComponent zeroes that out until it’s had a chance to string-pull.
So the AI will alternate focusing between the target point(when the direction is 0) and the TargetPoint + 500 units in the direction.
It seems possible that the CrowdFollowingComponent should probably simply not update the move focus if it cannot generate it yet (because of waiting on pending data).
Steps to Reproduce
Have an AI using the CrowdFollowingComponent, with strafe enabled, start moving to a point in the world. Move focus can get update back and forth between two values near the start of the pathing.
I tried looking at some of the links in that other thread that was referenced, but I cannot get them to load. I did look up the JIRA that was created, but there has not been any movement on it since it was created.
Have you tried removing the line setting the direction to a zero vector? I believe Mieszko’s comment from the other thread may be the best approach of creating a custom CrowdFollowingComponent and overriding GetMoveFocus with your own logic to avoid the zero vector being set.
-James
If you would like to use CrowdFollowing, we have an old open PR for adding support for multiple navmesh sizes. I believe it should work, but integrating it fully into the engine requires a lot of internal testing for us. It just has not risen in priority to a level to justify using our navigation devs limited time to fully investigate it. Here is a link to it on our GitHub: https://github.com/EpicGames/UnrealEngine/pull/2246. We will look into the issue with the jitter as well. Thank you for sharing out that it was working with that line change.
-James
Yes when I got CrowdFollowing to not zero out those values it worked, but I wasn’t sure of the knock-on effects there.
We ended up having to turn off CrowdFollowing anyway because it doesn’t work with multiple navmesh sizes, so this is no longer an issue for us, although it may still affect future developers.