Download

CODE REVIEW: StopMovementImmediately( ) method.

Hi, a small suggestion to future releases:

I have seen that this method doesn’t always works to stop movement, specially after the character movement being fired by SimpleMoveTo().
It’s because it doesn’t stops the PathFollowComponent by simply zeroing velocity.

So, I would suggest a small addition:



inline void UMovementComponent::StopMovementImmediately()
{
        Velocity = FVector::ZeroVector;
	UpdateComponentVelocity();
        // Suggestion
        UPathFollowingComponent* PathSys = GetCharacterOwner()->Controller->FindComponentByClass<UPathFollowingComponent>();
	if (PathSys)
	{
		PathSys->AbortMove(TEXT("Ordered by MoveComponent."));
		PathSys->InitializeComponent(); // <- If Reset( ) wasn't protected I would preffer instead of need reinit the comp 
	}
}


Hope it helps. :smiley:

Thanks for suggestion :slight_smile:

I assumed that all path following actions will be instigated by controller, but there’s no real reason for it and it should support unexpected stop. Will be fixed soon.