Tutorial: Custom Gravity in UE 5.4

i did not retried recently but i have the feeling it s because we are using a too recent VS version and module
seem s they are not supported yet

also i recommend you go see my screen shoot here i found more module hidden to install with various version (sorry that is in french. VS installation program dont give me choice)

Thank you sooo much for this - @Ari_Epic !
Implemented this on first person / VR character and basically is working :smiley: :star_struck: :partying_face:
i have quick question:
is there a correspondance for the ā€œgetRelativeGravityRotationā€ and ā€œGetGravtiyWorldRoationā€ functions in c++ ?
i couldnt find it there - using the character class.
Many thanx !

Thank you got your tutorial @Ari_Epic. I managed to implement this on the first attempt and have a nice (I hope) educational simulator developing on the back of it. Keep up the good work.

1 Like

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

Hey there, I followed your tutorial, but I don’t see the part where you explain how to make the planet itself and apply the gravity. Do you have a tutorial on this?

Hello, can you help me? I’ve been having a problem for days, I tried your attachment method, it works for me, but I’m feeling some tremors, it’s as if the player takes a few seconds to follow the rotation of the planet while I’m on the surface, it seems like a kind of interference, the player should be standing still on the surface, but I notice some tremors and inconsistencies, have you experienced anything similar? I tried several ways, I made a custom pawn, used the default unreal player, I tried several ways to attach and make the player follow the movement of the planet perfectly, but I always come across the same problem.

Did you ever solve this? I have the same issue. I have found it to be ā€œisFallingā€ in the navMovementComponent. Im not sure how to fix it though.

Here is an issue i am having while trying to do this in UE5.6.1

So i set up the GravityController and set it as my Player Controller Class and the controls were working fine then i set up all the blueprints perfectly but now the GravityController doesn’t work anymore, so with GravityController selected the player character doesn’t move, mouse, keyboard or controller doesn’t work, i checked ShowDebug INPUT and the mouse and keyboard inputs are being registered but no movement on the character.

If i change the Player Control Class Back to ThirdpersonMode i can then control the character and the gravity works with a bit of a crazy camera though, so im just confused if anyone else has this issue, is it a 5.6 problem or could it be that i was using a different UE Template then after setting up the GravityController i then add the ThirdpersonMode into my game so maybe to many controllers… my brain hurts

Seems the Third Person Template was updated in UE 5.6. I’ve modified the tutorial to take both the old and new templates into account. Try now!

2 Likes

Thank you so much for the super fast fix :slight_smile: im a bit new so sorry if i ask some dumb questions but when when changing the Parenting Class to the GravityController and clicking Reparent the Character Movement Component get removed and so all movement base node now have errors

Ignore me im stupid as hell… i change the thirdpersoncharacter parent class instead of the thridpersoncontroller blueprint :frowning: god darn it i read 1 word wrong and messed it all up hahaha

1 Like

hi, Thanks @Ari_Epic for the tutorial ! Everything works perfectly but did you ever noticed that in first person if you rotate the camera of 360 degrees too fast you end up see the character?
it looks like the character doesn’t update the movement according the controller rotation and get stuck in the previous rotation.
is something should adjust in the gravity controller in C++?

Thanks

I never tried it in the first person template, that one might need to be treated differently, but I don’t have time currently to look into it :grimacing:
If you figure it out, I’d greatly appreciate if you would post your results here :folded_hands: