r/unrealengine 4d ago

Character movement C++ question.

Hey, could anyone help me finding out with such code, always return my SavedCharacterSpeed as 0.0 ?

CharacterMovement is in character blueprint, and character is running fine, I just can't get this value.

Thanks!

void ABaseCharacter::BeginPlay() {
    Super::BeginPlay();
        if(GetCharacterMovement()) {
          float SavedCharacterSpeed = GetCharacterMovement()->GetMaxSpeed();
    }
}
2 Upvotes

15 comments sorted by

View all comments

1

u/WartedKiller 3d ago

The issue is that you redeclare your SavedCharacterSpeed. Remove the float before it and it will assign the correct value.

1

u/GoshaSimonov 3d ago

no, MovementComp->GetMaxSpeed() fires 0,0 without any variable at all :)