Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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?

Product Version: UE 4.19
more ▼

asked Jun 04 '18 at 01:34 PM in C++ Programming

avatar image

1 1 2 5

avatar image SeaShellWe Jun 04 '18 at 01:53 PM

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?

avatar image Tradestar Jun 04 '18 at 02:19 PM

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?


avatar image Tradestar Jun 04 '18 at 02:19 PM

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


avatar image SeaShellWe Jun 04 '18 at 07:47 PM

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

avatar image Tradestar Jun 05 '18 at 07:43 AM

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.

alt text

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

"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

more ▼

answered Jun 05 '18 at 04:15 AM

avatar image

36.7k 932 169 1111

avatar image Geffr Jun 11 '18 at 07:35 AM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question