Aligning pawn rotation on a sphere surface

I have a sphere on which I spawn a player character. When RMB is pressed and held with the cursor over the sphere, the player walks towards the point on the sphere.
I could not figure out how to adapt the default player controller to work with this, so I am writing my own movement controls.
The issue is two-fold:

  1. I need to maintain the up vector of the pawn to always be perpendicular to the sphere surface. (this I solved)

  2. I also need to set a new forward direction vector for the pawn, which ideally should combine into the solution of the first point.

I have found this here implementation which considers all axis for a generic OpenGL solution, but this does not work for me for some reason and I do not know if I made a mistake in the implementation or the concept in general.

This is the solution: opengl - Aligning an object to the surface of a sphere while maintaining forward direction - Stack Overflow

And this is my implementation in UE: Screenshot-23 — ImgBB

The Make Rot from Z node that is currently disconnected is the simple solution for the first point. It only aligns the up vector of my pawn correctly.

Edit: So i just had to sit down, look into the code and think. I had not understood FRotators. Now my finaly solution has been reduced to this: Screenshot-24 — ImgBB

1 Like