Tutorial: Custom Gravity in UE 5.4

Quickly added this to my First person project, it works great, except for one issue. It doesnt seem to rotate the capsule component, just the mesh. I cant get close to what would now be the wall on the -z side as my capsule is in the way.

As you can kinda see in the image, its offset to the -z direction. Is this fixable? or maybe just because I’m using the first person template?

The other issue is I’m doing a line trace(complex) in the gravity direction to get a new direction when walking over curved surfaces but I get a lot of jitteriness, even when I have the gravity with a VInterpTo node. The jittery might be when I’m walking past an edge on the mesh, but I figured the vinterp would smooth it out better…

1 Like

Hello
Could you please help with a problem in build.
I can’t build the code you gave in Visual Studio. What am I doing wrong?
I did exactly as in tutorial. Deleted all data that was in the file and pasted the code from you example. Did not write it myself, simply copy pasted.

is this replicated?

Hello @Ari_Epic how would I get objects like the cubes from the third player template to obey the new rules of gravity?

Error:And while following Unreal Univeristy’s tutorial for a main menu from 2 years ago, running the editor from from his main menu and pressing start the game level loads up with the gravity not functioning, but if I skip the main menu and run the editor directly into the game level, new gravity works. Could anyone help?
Edit: Solved The game needed more time to load inbetween level changes, character would spawn faster than the level and events failed to fire.

@StellarDrop

Could you please share a picture or pictures of how you’ve achieved the camera stability using your method of detachment

Ive been painfully trying everything to follow what you’ve suggested and anything i can think of for months to get my camera stable, all in vain

I Would greatly appreciate it
Thank you

Thanks for this Custom Gravity code!
Custom gravity is working with the Walking movement mode but not Flying.
How do I ensure custom gravity works with all movement modes?

Update: I’m going to create a UPlanetaryMovementComponent class that inherits from UCharacterMovementComponent to allow for all Movement Modes with Custom Gravity.

@Interitus384 I got the capsule to rotate properly by using a hit event and tagged “wall” and if true set new gravity to normal of the wall (negated) also rotated the capsule using the same hit normal negated.
The risk is if the hit event is on an uneven surface the capsule will also be and remain so untill corrected. You could do this with a time event and line trace.

I’m curious, did get the camera/aiming pitch and yaw working correctly while on walls or ceilings?