1. Place Cameras in the World

If you are new to Unreal Engine 4 (UE4), you might want to read our Programming Quick Start tutorial first. For this tutorial, we will assume you are familiar with creating a project, adding C++ code to it, compiling your code, and adding Components to Actors in UE4

  1. We will begin by creating a new Basic Code project, with starter content, named "HowTo_AutoCamera". The first thing we'll need to do is create two cameras in our world. Since there are multiple ways to set up cameras, we'll go with the two most common ways here. For our first camera, go to the Modes tab in the Placement Browser and click Place, or press Shift+1. In the All Classes section, you'll find a Camera actor. Drag this into the Level Editor and position it so that it has a good view of our scene.


    When this is done, the Level Editor window will have a picture-in-picture view of what our new Camera Actor can see as long as we have the Camera Actor selected.


  2. For our second camera, we'll use a method that goes a little more in-depth and gives us a little more control. Start by clicking on Basic in the Mode tab in the Placement Browser and dragging a Cube into the Level Editor window.


    We can use almost any actor class for this step. The MyActor class we created in the QuickStart tutorial might be interesting to substitute for the Cube.

  3. When our Cube actor is placed, add a CameraComponent by clicking the + Add Component button in the Details panel for the Cube. You can now set the position and rotation of that CameraComponent to give us a different view of the scene than the CameraActor we placed earlier.


  4. We should customize our CameraComponent by turning on Constrain Aspect Ratio so that it matches the setting on our CameraActor. This will make transitions between camera views smoother, but it is not required.


With our world set up, we're now ready to create the class that will control our camera view.