Rotate Camera C++

Hi all,

I want to rotate camera when game starts with the code below.


Only the code for change location works but SetActorRotation(this->CameraEntryLocation) does not work.
How can I fix this?

Just to clarify: Your code gets the “ViewTarget, which is the primary actor the camera is associated with” (UE4 Doc PlayerCameraManager), in most cases the PlayerCharacter of sorts. Therefore your code would be modifying this Actor, and not the camera. This is contradictory to your title, so I have to ask whether this is an error?

According to your comment, I could have made an error in my approach to solve for camera rotation.
Could there be a correct way to rotate the camera?


I tried the following code as well but did not work:


What exactly do you want to achieve? Rotate the camera where? Input-based or to a fixed position? Is the camera attached on a spring arm, attached to an actor? Please add more information to your question, since I’m not sure what your goal is

“ViewTarget” is actor that is currently display. The way it is work is, on every frame PlayerCameraManager ask ViewTarget (a actor) by calling it’s function CalcCamera() to get camera position, so it kind of like asking how actor which to be displayed:

The default code inside AActor class CalcCamera searches for active camera components inside the actor and it gives out world position of first active camera component inside Actor, so by default location of camera component inside the actor controls camera view. You have 2 options:

-Either change position and rotation of camera component (or place camera component if it’s missing) inside ViewTarget actor

-Or override CalcCamera function of Actor you use as ViewTarget to manually output camera positioning

Note that by default Possessed actor by PlayerController automaticly becomes ViewTarget, you can disable this behavior by setting bAutoManageActiveCameraTarget to false in PlayerController

1 Like

I want to rotate the camera to a fixed position, say, (Pitch=-44.0,Yaw=1.5,Roll=0.0) when the game is played. The camera is the default that comes with the PlayerController blueprint.

Looking for solution to this as well. Anyone with an idea?