How to make an object walk and jump around a 3D sphere?

Godot Version

4.4

Question

Please see this video about 10th second onward: https://youtu.be/WjowRuSlRbc

So in that video, you are on a tiny planet and you can run freely around on that planet. You can also jump around as well.

The Godot 3D tutorial teaches how to move on x and z coordinates but if I am to move an object like in that video, I believe the following need to be answered:

  1. How to set gravity angle for the object? This is so you could run around on the sphere, and when you jump, you will know the angle that you will jump will be the opposite of the gravity. Do we have that built-in for Godot?

  2. From Godot 3D tutorial, a simple thing to do for jumping would just mean setting Velocity.y and everything will just work. But in this case, since the angle of the character could be arbitrary in the 3D space, how to do this?

  3. Since you now no longer move on a simple 2D plane with gravity at the bottom, how would we calculate when the character moves around on the sphere in this case?

So for now, I am stuck on the math that would make this work. Can anyone give me a hand on this?

Help > Programming 3d

I just rotated the planet below the player instead of moving the player.

I’m too tired to look now, but there was a long discussion about how to do this a couple months ago on here. The solution was to point the gravity normal always to the center of the planet. After that discussion, I decided to try my rotate the planet idea. It mostly worked great.

@dragonforge-dev

For a more simple case that you know you definitely only need that, that will work, but for my case though, the reason I asked “around a 3D sphere” first, is because later, there will be other shapes, and I am to move objects on those 3D shapes too. If you could figure out the math, then this should be a breeze afterward.

By the way, do you still recall the name of that thread you mentioned of?

I think this is the topic: 3D rigidbody movement around a sphere in Godot4
This discussion will answer at least two of your questions thoroughly.

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.