Override OnMovementModeChanged causes Jump lag

I have overwritten OnMovementModeChanged function found in CharacterMovementComponent. The issue is that whenever the code is used, it causes a delay with the in-engine jump function.

For example, whenever the code is compiled and used, I have to push the jump button twice before I can jump again. Even if I wait several seconds before pushing the jump button, it still requires me to push it twice.

I know the code is the issue because when I take the code out and recompile, I can push the jump button as soon as the character lands, and the character will jump again.

Perhaps I didn’t override it correctly?

Header File:

virtual void UCharacterMovementComponent::OnMovementModeChanged(EMovementMode PreviousMovementMode, uint8 PreviousCustomMode) override;

C++ File:

void AClassName::OnMovementModeChanged(EMovementMode PreviousMovementMode, uint8 PreviousCustomMode)
{
PrevMovementMode = PreviousMovementMode;
}

Alright, so after so more research, I found my answer. The issue was that I didn’t call the super when I over wrote the OnMovementModeChanged function.

.h file

virtual void AMyClassName::OnMovementModeChanged(EMovementMode PrevMovementMode, uint8 PreviousCustomMode) override;

C++ file

void AMyClassName::OnMovementModeChanged(EMovementMode PrevMovementMode, uint8 PreviousCustomMode)
{
	Super::OnMovementModeChanged(PrevMovementMode, PreviousCustomMode);
	
	/* Your logic goes here */
}

Do the following and you will have no issues creating your own logic or setting variables (like getting the previous movement mode).

1 Like