Tutorial: Custom Gravity in UE 5.4

I think there’s an issue in AGravityController::UpdateRotation where the parameter of P->FaceRotation is still in gravity space. However, FaceRotation needs to be in world space.

Additionally, FaceRotation generally requires removing the roll and pitch in gravity space before converting it back to world space. But we cannot handle this in the UpdateRotation function, because the FaceRotation function is not only called here—it is also invoked by the CharacterMovementComponent on the client side during networked gameplay.

Therefore, we should override the Character’s FaceRotation function to handle the conversion to gravity space, remove the roll and pitch, and then convert it back to world space. Also, we need to enable the Pawn’s three properties: bUseControllerRotationPitch, bUseControllerRotationYaw, and bUseControllerRotationRoll.

3 Likes