Something like sticking in 3D space. the camera would be placed behind the player.
How can we make the object we are moving on the wall, ceiling and floor? 3D
If your levels are predefined: you could use a Path3D node and something like a PathFollow3D node to calculate the position the player would be at along the path/curve.
If you are looking to do this dynamically, not using predefined paths or levels, then I would recommend using raycasting to tell which surface(s) the player is nearby. Then based on the surfaces the player is nearby/on, you could have a script that changes how the player moves. (At least, theoretically. I haven't done a mechanic like this myself)
Ray casting would work. You would need 4 rays in the example photo (or 6 if you could go in all directions). For example, facing straight down, straight forward, etc.. Then check if they are touching a floor/wall. You'd probably need to take care in the corners as to which wall you are supposed to be on, but it should be possible.
You might be able to use a set of Area's. Using the Areas you can define gravity directions. They can override your current gravity.
yet ANOTHER way would be to reference the polygons normal the ball is sitting on at the time, and use its direction as the up vector. Move_and_slide uses an up vector in its 2nd argument...
move_and_slide ( Vector3 linear_velocity, Vector3 up_direction=Vector3( 0, 0, 0 ),.....
Not sure exactly how to get this working, but im trying to (need to, rather) do something similar. I think it would then need to pass in the next polygon it hits as the new normal to reference from a collision detection.
If you figure it out, post your results for us all!
Get polygons collided with and take an average? Otherwise you need some special case for switching between them..?
We can use rays and change gravity to make them stick to the walls based on the vectors.
$Ray.get_collision_normal()
Output:
(0, 0, -1) or (1, 0, 0)