How to set fixed speed to Character?

REFERENCE VIDEO

I’d like to achieve this kind of movement.

  • When the player walks, its speed is fixed to 320 ups (units per second)
  • When the player jumps, it has to fall quickly to the ground and not slowly (like Unreal Engine does by default)

Keep in mind that I will have to introduce Strafe Jumping at some point and the Units Per Second (UPS) will have to change depending on the player’s movement skill (rotates the mouse in sync with A-D).

I’m absolutely ignorant when it comes down to Vectors, Physics and Cinematics.

For this reason I hope you will guide me the right way.

Thanks in advance.

P.S: For now, I’ve just set **GetCharacterMovement()->MaxWalkSpeed = 1320; **in the Character BeginPlay()… but I don’t think it’s the best solution because before reaching 1320 the Character starts slow!

I’m assuming you have something along the lines of



void ACharacter::MoveForward(float Value)
{
    if ((Controller != NULL) && (Value != 0.0f))
    {
        // find out which way is forward
        const FRotator Rotation = Controller->GetControlRotation();
        const FRotator YawRotation(0, Rotation.Yaw, 0);

        // get forward vector
        const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
        AddMovementInput(Direction, Value);
    }
}


in your character .CPP file? You could replace Value in AddMovementInput(Direction, Value); with a variable of your choosing that always has a base value of 320.f So every Tick your character would move 320 units. Then just update the variable you choose to use depending on character skill. I haven’t tested this but it seems like it should work for you.

As for the jumping stuff. You could increase the Characters Gravity scale to something like 20, and change your jump velocity to something ridiculous. You’d have a quick up and down jump.

You’re conflating Acceleration with Velocity. Velocity is the maximum speed an object can move (in m/s), where Acceleration is how quickly that object reaches that speed. You likely just need to increase the player acceleration in the character movement component. Same with gravity, just increase it for the character (Gravity Z scalar) if you want them to fall faster.

The Value of the function will be either 1 (forward) or -1 (backwards). So I’m sad to say that doesn’t work… :frowning:

For now I really just need to set the Player speed fixed to 320 ups. Strafe Jumping will be implemented and it will allow players to exceed that initial velocity (320ups).
But for now, doing both is just too much for my competence.

For this reason I’d like to at least achieve the fixed speed of 320ups… but I can’t understand how.

The problem with a higher GravityScale is that the player will get back to the ground faster only because the jump height becomes smaller!

What I observe by setting bigger values to GravityScale, is that the Player jumps less because more gravity keeps him attached to the ground… which is different from falling faster!