Setting the Character Movement Component's Gravity Scale with C++ in Unreal Engine 5

Real quick let's have some fun setting the gravity scale in the movement component

Unreal Engine 5 Quinn and Manny third person characters floating in the air in the GD Tactics Gym
Manny and Quinn floating

Game Engine

Unreal Engine 5.5.3

IDE

Rider 2024.3.5

Project Name

MyProject

OS

macOS Sequoia 15.3.1

When making the Coyote Time post I wasn't sure if I wanted to adjust the gravity of the player when they walked off an edge. Regardless, I wanted to know how to do it in case I ever wanted to do it in the future.

Updating the gravity scale is very simple. Inside the third person character do GetCharacterMovement()->GravityScale = 0.5f, set the float to your desired value.

GetCharacterMovement()->GravityScale = 0.5f;  // Adjust the float to your needs

The float will be multiplied against the current gravity affecting the character. So if the value is 0.5f it'll be half the gravity giving the player more float as they fall and if the value is set to 2.f, it'll be twice the gravity pushing the player to ground faster.

Have fun floating around.

Comments (0)

Add a Comment

Sign in to comment or like.

Delete Comment

-