Planetary Physics in UPBGE 2.79

Hello All!

I am trying to make planet physics in my UPBGE game where all objects obey gravity relative to the center of a sphere. I have tinkered with a couple of tutorials to no avail which, on the surface seem simple, but I cannot get to work properly in UPBGE. Any ideas on how to do this? Nothing fancy, just local/global gravity set to the center of a sphere as opposed to the Z axis.


Did you try this tutorial?

I’ve used it a few times over the years.

Yes I did! For whatever reason I could get it o work in BGE, but not UPBGE. Weird, I know.

Hmmm… they probably changed the API’s a little bit. What kind of errors do you get in the UPBGE console?

It’s been a while since i’ve run through that tutorial. Hold on, let me see if I can pull the file back up… I do remember that there was a python error and the gravity just reverted to the standard bullet physics gravity.

okay so I remember what happened with that particular tutorial. I couldn’t get the player to stick to the planet, it would just continually fall off even though the “gravity” property was set to the player. I thought at first it might have to do with the character physics being set, but that wasn’t it. Here’s a reference .blend for more info. Press “W” to move the character forward. planet_physics.blend (818.7 KB)

Did you set the world gravity to zero ?

Edit: I see that you did. Hmmmm, now that is interesting.

Ah, I found the error. You set the controlled objects physics to character. I’m not sure why, but that particular setting cannot be used. I guess it is because that physics is made for games where up is Z+.

Change it to Rigidbody or Dynamic and it works : D

1 Like

Awesome possum! Thank you!!! Now the trick is to try to figure out how to make it work with the character physics…

I’m not sure it is possible :thinking: I don’t think the character physics can properly handle multi axis rotation.

In the file you uploaded it falls down the Z- axis no matter how you set the rotation, and even though you disabled world gravity.

If I understand character physics correctly, it is only meant to rotate around the world Z axis, and upwards is defined as the world Z+ axis.
In other words, it is specialized for flat worlds and so cannot work properly on round ones.

What do you need the character physics for?

Well, I guess the character physics aren’t entirely necessary, I just like the ability to be able to set a max jump number, angle limits and to get rid of that stupid sliding that always happens with Dynamic and Rigid Body physics :upside_down_face:

Hmmmm… I understand. I think you will have to replicate them with custom python scripts.
Hmmm … If I recall correctly, @BluePrintRandom covered most of what you asked in another thread recently.

The sliding can be solved with either material friction or damping in code.

What do you mean by max jump number?

Edit#00: Found it. A variation on the last line in the script should get you the basics for the character to stop slipping.

Edit#01: I know what you mean by max jump number now. This too can be replicated in a script.


yeah - take my script and replace @ with * and it should be good to go