Vectors on a rotating sphere

Godot Version

4.1.4

Question

I would like to make a character stay on a rotating sphere without parenting it. I take the axis the sphere is rotating on and cross it with Vector3.UP. this gives me direction of the spin. This works great until you get close to the actual rotation axis, as it is a constant. I have tried to cross the rotation axis with the direction from the planet to the player, but because the player is technically always moving and the players basis is set to align with the planet, the vector for moving the player rotates just like the planet.

Does anyone know a good way to get something to stay on a spinning sphere.

player.gd basis set

	transform.basis.y = (transform.origin - planet.transform.origin).normalized()
	transform.basis.x = transform.basis.y.cross(transform.basis.z)

planet.gd setting the players transform

		var body_distance = (body.global_position.distance_to(global_position))
		var body_direction = body.transform.basis.y
		var body_axis = -(body_direction.cross(rotation_axis)).normalized()
		var body_displacement = (body_axis*(body_distance*rotation_speed))
		body.translate(body_displacement)
		body.orthonormalize()

Maybe you could get spherical coordinates, from players initial cartesian coordinates. Then if the sphere rotates, update this spherical coordinate and set the players global position to it. You could also use the look_at method if you need the player to orient towards the center of the planet.