Best approach for different gravity
We are working on a prototype that requires the player to be able to walk on planets, and float in space when not in range of the planets gravity field. This means the gravity should be calculated depending on the characters position in space (And offcourse any other object with physics assigned).
Now the way UE4 handles gravity is a float variable on the Z axis that is set to -1. This can be changed to +1 or 0.5 or something. Also this is set on starting the game, and is not changed during runtime, and also locked on the map, and not different for every player. This is obviously not what we want to use. We have to create a whole new way of calculating the gravity for each player individually.
Now I did some research, and also tried some things, and I came up with 2 solutions. Either I am going to ignore the whole UE4 gravity, and put everything in the world to my own gravity calculation. But this would mean I can also not use the basic character movement and have to write it all for my own.
Or I could throw away the way gravity is calculated in UE4, and change it to the way I want. But this means changing the way the engine it self handles gravity, and could also be a risky approach (I think).
Any tips how this could be achieved in the best possible way? The project is not in a hurry now, and before breaking apart anything I would like some tips, and maybe someone here has done this already and has some ideas how I could do this.
Thanks in advance
I recently made a pull request that does this.
You can call SetWorldGravity from the Level Blueprint with a vector and gravity for everything in your world will change to that vector.
If you only want the characters gravity to change, you can call SetGravity on it. You will still need to calculate the vector you pass to it based on the characters position in space, but thats all. (You will also need to adjust the camera and input controls to work for non-Z only gravity)
answered Nov 20 '15 at 07:39 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here