Planet Directional Gravity - Problems creating reference vectors in center of sphere (finding angles from normal vector etc.)

Really struggling, and would appreciate input from math wizards.

Link to video example: Reddit - Dive into anything

To simplify finding the normal and forward vector direction of a character, I created a reference cube that rotates at the center of the planet. The top of the cube points towards the player character and rotates according to the x/y angle from +Z or -Z (top or bottom of the planet)

However, when z approaches 0 at the equator the angle calculation doesnt seem to work properly. Also there seems to be a lot of issues at the poles.

How can I make the movent of the cube follow the player positon perfectly? What am I missing?

Link to original concept diagram:

https://www.reddit.com/r/unrealengine/comments/13qjejq/help_a_blueprint_noob_how_do_i_achieve_this/
Full Blueprint:


Planet Center to Player Vector:

Top of Planet Rotators

Bottom of Planet Rotators

You’re suffering from ‘gimbal lock’. Too long to explain :slight_smile:

I suggest, it’s best to either follow a working tutorial, like

or use an easier technique, which is just aligning the player to the mesh normal.

Thank you! Why do the answers always look so obvious and simple when looking in the rear view mirror? Here is what I used ⇩


1 Like

Much better :slight_smile:

Like I say, it’s also possible to make a pawn which does a downward trace and adopts the location and normal from the surface.

That way, your planet can be any shape :smiley:

1 Like