Camera flipping on rotation issue

Hey there, I had a similar question related to this issue, But this was a more specific problem.

**What I’m doing: **
I’ve got an Actor blueprint which has a SpringArm and camera attached to it. I’m Rotating and setting its location to be at the center of both (2) players.

**The Issue: **
When the Cameras actor rotation reaches a 90 or -90 degrees, the camera suddenly does a 180 flip.
**Video Showing the issue: ** CameraRotation problem - YouTube

How can i get rid of this unwanted behaviour?

Thanks in advance!

I think there is a problem in using FindLookAt results, but this is really not a point.

For now you need to understand a logic of this camera setup.

Two characters can be on right and left side of a camera.
For example, P1 on right and P2 on left. SpringArm location will be:

(P1.location + P2.location)*0.5

Rotation can be calculated according to character’s sides.

RightVector = P1.location - P2.location
CameraYAxis = Normalize(Vector(RightVector.x, RightVector.y, 0)

But here is one problem. What should happen if characters change sides? When P1 make some big jump and pass location of P2. In this case, with this math, camera will flip. Maybe not instant flip, but it will.

So… Camera rotation should depend on some right and left side, but it shouldn’t depend on which character is on that side.

Hey, thank you redbox again for the answer. I’ll give this a try and report back later.


I Finally got it working! I Used the math you presented to get the correct answer, thank you so much =)!

Here is the final solution in blueprints.