"Orbiting" the player around a child sphere

(Using Godot 4.6)

I’m relatively new to Godot and Gdscript. I’m currently stuck on making part of my character’s moving system. I’ve tried to do some research on this but I haven’t found anything that works yet.

The player is a CharacterBody3D, and the script is comparable to the default movement script. It can move around just fine.

There is a ball object also in the scene. The player can walk up to it and interact with it, in which case the balls visuals and collider get parented to the player (and when unequipped are put back in the parent node). Then, as the player walks, the visuals+collision will rotate around in place so it appears as though it’s being rolled.
(As a side note, the ball’s rolling is controlled in the ball’s script, not the player’s)

My current issue:
I am trying to add a movement function only when both the ball is equipped and either actions ‘orbitLeft’ or ‘orbitRight’ are being held down (Mapped to Q and E). What I want to do is have the player walk around the perimeter of the ball (ideally with the camera following) in those directions, without the ball itself actually moving while the orbiting is happening.

I can supply parts of scripts if needed. Any help is appreciated!

Your description of the problem is not clear enough. Post a mockup or some drawings or example from an existing game.

1 Like

I’m making an altered version of the moving/rolling system in Katamari Damacy. Instead of just rotating the camera to look around/navigate, you move around the katamari (the ball).

I’m unable to easily screen-record on my current device, but if you skip to about 2:15 in this video, you can see the orbiting movement.

(It’s the only video I could find that included the tutorial, which is the easiest in-game place to see it)

So you want to pivot around some arbitrary point?

  • translate the player so that their origin is at the pivot
  • remember that translation in player space
  • rotate the player using axis/angle
  • translate the player back using the reverse of the remembered translation in player space

Or:

  • temporarily parent the player to a dummy node positioned at the pivot
  • axis/angle rotate the dummy node
  • unparent the player
2 Likes

Thank you!

I had to redo a bit of the movement system to be able to accommodate, but the first method works great! :]

1 Like