Download

On Movement Changed function doesnt match up with bp version

why are these two different? the c++ version has only two params while the bp one has 4


Annotation 2021-10-13 123546

Both versions actually exist in C++.
The first is the one you override in your ACharacter derived native class:
virtual void OnMovementModeChanged(EMovementMode PrevMovementMode, uint8 PreviousCustomMode = 0);
The second one can only be implemented in blueprint:

UFUNCTION(BlueprintImplementableEvent, meta=(DisplayName="OnMovementModeChanged", ScriptName="OnMovementModeChanged"))
void K2_OnMovementModeChanged(EMovementMode PrevMovementMode, EMovementMode NewMovementMode, uint8 PrevCustomMode, uint8 NewCustomMode);

The implementation of OnMovementModeChanged in ACharacter calls K2_OnMovementModeChanged while passing CharacterMovement->MovementMode and CharacterMovement->CustomMovementMode as the New Movement Mode and New Custom Mode respectively.

I guess these two additional parameters are passed to the BP version to save the overhead of having to call two additional getters if the are needed. In the C++ version you can directly access these from the movement component the same way it’s done in ACharacter::OnMovementModeChanged.

this is how i was able to replicate it in c++.

is it gonna work same as the bp?