Help with cameras. Tried everything, losing patience.

I have a ball game. It has two camera viewpoints. One is behind and angled towards the player’s ball and the other is a world camera at 0,0,6000 that looks down 0 -90 0 on the play space.

The game most resembles a pool or billiards game in that its turn based, when its the player turn it switches to the player’s perspective and when its not it switches to the world camera. And like a pool game, its always nice to see your cue ball in relation to the other balls.

I had these two systems working simple enough with Set View Target with Blends but I found some of the blends jarring and wanted to smooth them out. So I sought to add one more thing, when the player’s turn is over, get the player’s Z rotation and then sort what ranges it fell in to out of 360, for example the ranges are -45 to 45, 45 to 135, 135 to -135, -135 to -45). I then wanted to rotate the World Camera’s Z axis to snap to a perpendicular degree (0, 90, 180, -90)

Basically, if the player’s ball’s rotation was 0, 0, -175 it would rotate the world camera to a value of 0, -90, -180. That way when I Blend from the player camera to the world camera it has fewer degrees to rotate because the world camera is generally aligned with where the player was already looking. My problem was the blends didn’t care at all that I was rotating things for them to make them happier. They still did insanely squirrel rotations, often doing 360 degree turns or what felt more (hard to tell with a 2 sec blend time sometimes). In the end Set View Targets are just really inflexible.

I’ve since tried to interpolate/lerp between the positions/rotations to no avail and I’ve tried several times… are cameras unique in that sense? I actually had mixed success using the Move Component To and it would actually have worked beautifully if it worked on world rotation.

I guess, I’m lost on how to proceed. What would be the best way to handle this? I’ve tried using one camera and moving it, I’ve tried having two cameras and blending between them in the same blueprint… in different blueprints. I think I just need a second opinion on what would be the best setup for this in case I already tried it but perhaps my logic was bad… I don’t know… its late… 3:21. ugh.

Hello sarchasm,

It seems like what you’re running into is the brick wall with rotation called Quaternions. Quaternions are used in UE4 to keep rotation consistent in a 3D space, but cause some odd behavior with rotation if you’re using degrees for everything. One way to see this is to do something such as adding a small amount of rotation on a timeline or on tick and watch what happens to the values if you try to make the object Roll 360 degrees.

One way around this would be to use the Rotating Movement Component to handle your rotation as it is already set up to handle Quaternions, which could be tricky with your set up so that may not be the best bet. The other would be to convert all of your values into radians during your calculations and then back to degrees when you’re setting the values.

I hope this can help point you in the right direction.

We haven’t heard from you in a while, sarchasm. Are you still having issues with your camera rotation? If so, was my previous post of any help? I’ll be marking this issue as resolved in the meantime.