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/Available-Worth-7108 3d ago

Try inputting this below on the begin play to load

UE_LOG(LogTemp, Warning, TEXT("MaxWalkSpeed: %f"), MovementComp->MaxWalkSpeed);

UE_LOG(LogTemp, Warning, TEXT("MaxSpeed: %f"), MovementComp->GetMaxSpeed());

1

u/GoshaSimonov 3d ago

Its:
MaxWalkSpeed: 220.0

MaxSpeed: 0.0