[Find Look at Rotation] unwanted 180 yaw rotation at pitch = -90/90

When you set a player directly above the world and you set it’s rotation to look at the world (0, 0, 0) then when the player passes directly above the world it will rotate and keep staring at the world, but is there a way to keep the orientation of the player still facing forward while staring at the world?

Example:

World = A Large Box centered at (0, 0, 0)
Player = A player standing on top of the box ex: (0, 0, 10)

When the player goes from (1, 0, 10) → (0, 0, 10) → (-1, 0, 10) the player will rotate around 180 degrees, which I do not want. I want the player to keep facing the forward direction he originally was while still staring at the center of the world.

Hi

Just need a but of clarification.

I want the player to keep facing the forward direction he originally was while still staring at the center of the world

It seems you are asking to face 2 directions at once. Forward and the centre of the world / Box.

Can you shed some more details.

You might be able to use Look Up Rot, to start with then disable that vector for future calculations.

I think you might be encountering the Gimbal Lock problem,

You need complex quaternion math to solve it…
So the best you can probably do is PREVENT it from happening (often looking completely up/down)

LookAt is really just simple vector math:

  1. Determine an arbitrary “up” direction (by default this can be Z, but you can choose whatever you want)
  2. Determine the “forward” vector you want.
  3. Generate a “right” vector by crossing “up” with “forward”
  4. Generate a new “up” vector by crossing “forward” with “right”
  5. Normalize the vectors
  6. You now have a right/forward/up left-handed basis that you can plunk into a matrix to make your orientation

You get the problem you describe when you “forward” equals “up” (or negative “up” – technically, they become linearly dependent.) The easiest way to fix that is to detect that the cross product between up and forward is very small. When that is the case use an “alternate up” vector – perhaps one that’s sqrt(0.5)*(Y+Z) instead of just Z.
There will still be a discontinuity around the area where you decide to switch up vector. You can make this softer by lerping between the two up vectors based on how close to singular you are.

If you want a physics type scenario of this it would be the hairy ball theorem. it comes down to the fact how you can’t fully comb a hairy ball to all go in one direction. There will be a south and north pole where the hairs contradict. The same thing is happening in my case where when the player reaches the north and south pole the camera will do a full 180 degree rotation.

I may have been unclear what I wanted but, it suppose to be a top down view of my player who is circling a box(planet). The camera would follow it perfectly with a simple look at feature, but when it hits the north and south pole, the camera does a flip.

I have the same problem… my “turret” just turn on -90 / 90 degrees… also my pawn location is negative…
anyone??
thanks!

Hi @jwatte, seems like you know your math, so this approach you describe. Is there any chance you can create a BP that does that? I currently only have two points (positions of two motioncontrollers for VR). Do i use that vector between those two points as forward vector? and just use z-axis as up vector as default? If so, then i got that part done, but then you lost me when u said, i can plunk those into a matrix to make my orientation? Do you mean “Make Rotation from Axes”?

This btw, does NOT work. It still flips out at forward pointing up, and actually makes the orientation jitter around, probably because the up-vector changes constantly. And also the axes are flipped once i move one controller behind the other. See recording here:

[Video showing behavior][2]

Hi I found the correct answer to your problem. Heres a link to the solution.