How do you rotate the player's camera from C++?

I am trying to find the equivalent of this in C++:

I don’t know what I’m doing wrong exactly. I tried using the AddActorLocalRotation and AddActorWorldRotation functions from the PlayerCameraManager as well as trying the solution from [this][2] topic and then attempting to use the AddLocalRotation, AddRelativeRotation, and AddWorldRotation functions on the UCameraComponent reference that I found but none of these things made the camera rotate. Am I missing something here?

I found the solution to the issue thanks to another community member pointing me in the right direction. My Default Pawn class is a character class named TPlayer.

First of all, in the header file for TPlayer, I included the UGameplayStatistics header file:

276195-gsinclude.png

Next I created two pointers to reference the character and the camera component:

276196-refs.png

After this I assigned their values:

276197-assign.png

And finally I can rotate the camera like so:

276198-rotate.png

I hope this answer can assist other people in the future that ran into the same issue or a similar one.

1 Like