Hi, I had a lot of attempts to figure out how can I change gravity force direction and finally nothing gain!.
I look at PhysLevel.cpp file, it was only for level’s actors, not the character, then searched in CharacterMovementComponent.cpp and nothing found.
Anyone can help me to figure out how can I change gravity direction for character movement?
To my knowledge you can’t change the direction of the default gravity mechanics. The workaround would be the following: Turn your characters gravity off. Then go into the Tick function of your character, and apply a force to it that has the same strength as gravity (gravity force is 9.81 m/s²) into the direction you want. So lets say you want your gravity to work along the X Axis: The vector you would use for your force would be X=9.81 * DeltaTime Y=0, Z=0. This should do the trick.
Thanks for your reply.
I’ve tried to do some different method like what you said to implement dynamic gravity but each method had a few bugs and wasn’t clear and comfort to play.
If you are willing to implement the movement logig yourself, you could ditch the character and start a new pawn that has custom behaviour. Implementing movement logic is pretty easy, and you had full controll over the dimension you implent it in. The stadard character expects to always have gravity downwards, so its movement logic is custom tailored to that.