I’m programming a very simple game because I’m new to UE4 and I still have a lot of things to learn, so there’s a 99% chance that I’m making a stupid mistake here.
In short, I have a ball that rolls around according to my inputs, and I’m trying to control the camera with my mouse: it needs to rotate around the pawn according to the mouse movement while always watching the pawn itself. I have been able to make it move around the pawn (basically it moves on a sphere centered on the pawn), and I was trying to make it always face the pawn regardless of their relative position. And I actually succeeded in doing so. The problem is that now a weird error appeared, even though I left the code unchanged, and in fact I’m quite sure the code is perfectly fine. Inside the editor it seems to me that both position and rotation of the camera change as expected, while if I hit play the view is fixed in a given rotation and it doesn’t change nor by input nor by manually changing camera rotation in code or in the detail panel. Notice that the view in simulation mode follows camera position, only its rotation doesn’t match camera rotation.
As you can see in the first picture, the camera is slightly titlted downward with respect to the pawn, as I set in my code. The second picture shows what I see when I hit play: the view is horizontal and it doesn’t change when I move the mouse (while its position with respect to the pawn does).
The line of code that rules camera rotation is
BallCamera->SetRelativeRotation(FRotator(CameraPitchAngle, CameraYawAngle, 0))
where the two variables CameraPitchAngle and CameraYawAngle are changed via input. But I want to stress that my code worked in a first moment and the camera is actually rotating, but the view during simulation doesn’t follow the camera anymore.
Any clues? ^^