Hello, I’m currently implementing an NPC movement (together with MotionMatching locomotion) and testing possible corner smoothing while moving using the PathFollowingController.
I’ve noticed that PathFollowingController only follows points on the path and, in the end, adds a normalised movement input to the NavMovementInterface like so (MoveInput implementation in the code snippet).
Therefore, there doesn’t seem to be any information on a possible next point and additional information to apply corner smoothing based on the predicted path.
Is there such a system implemented/planned that would make turning corners smoother and more precise?
Currently, the agent tends to drift out of the corner until the velocity catches up and corrects the movement to aim at the next point. This might cause the agent to bounce into walls or miss potential doors behind the corner. The only thing I have found that fixes this drift is increasing Ground friction on the actor. This change, however, makes the turning too precise without any curving at all, and the agent follows the rigid path perfectly without any smoothing whatsoever.
`// MoveInput implementation
void UPathFollowingComponent::FollowPathSegment(float DeltaTime)
{
[…]
CurrentMoveInput = (CurrentTarget - CurrentLocation).GetSafeNormal();
NavMovementInterface->RequestPathMove(CurrentMoveInput); // <<
}
// Friction implementation
void UCharacterMovementComponent::CalcVelocity(float DeltaTime, float Friction, bool bFluid, float BrakingDeceleration)
{
[…]
else if (!bZeroAcceleration)
{
// Friction affects our ability to change direction. This is only done for input acceleration, not path following.
const FVector AccelDir = Acceleration.GetSafeNormal();
const float VelSize = Velocity.Size();
Velocity = Velocity - (Velocity - AccelDir * VelSize) * FMath::Min(DeltaTime * Friction, 1.f); // <<
}
[…]
}`