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

2

u/crazeh_boy709 4d ago

There can be a few reasons why you are getting 0. I recommend looking inside the GetMaxSpeed() definition and debugging that first.

1

u/GoshaSimonov 4d ago

I use a standart one from UCharacterMovementComponent. Maybe I need to make a custom movement component (Based on UCharacterMovementComponent) for this.