Unreal Engine 4 Tutorial: How to change the default camera Wednesday, January 20, 2016
programming ue4

Intro

In this Unreal Engine 4 tutorial I will talk about how to change the "default camera".

For one of my projects (A 2D side scroller) I wanted to have a camera actor as opposed to a camera component attached to a player character, like in some of the engine sample projects.

I also wanted to have full control of the behavior of the camera and I did not want to worry about the camera after the character was destroyed. If you think about it, if the camera is attached to the character as a component, once the character is destroyed so is the camera.

Here is how I went about getting it done. Keep in mind that this is just one way to go about it.

The GameMode Blueprint

Get Camera Ref Blueprint

In the GameMode blueprint event BeginPlay we loop through all the actors or type DefaultCamera and look for the one also tagged DefaultCamera and store a reference to it. We then call Set View Target with Blend to "aim" the camera at the player. Looping through all the actors of type DefaultCamera may seem overkill but it allows me to re-use the class but have only one be the main or default one.

My apologies for picking a tag name that is also the name of the blueprint. MainCamera would have been a better choice.

DefaultCamera is a simple blueprint I created to program the logic of the camera movement.

The Camera Blueprint

Default Camera Blueprint

This is a simple camera that fallows the character around ignoring the Z axis (Up) changes of the character position so if the character jumps the camera does not. Your camera can do whatever you want.

Final thoughts

While I chose to adjust the camera under the BeginPlay in GameMode, you can also do it in the BeginPlay event of the actor containing the camera component.

For this game, after the character dies, the camera stops moving (since there is no character to follow) and a retry UI is presented. If the player desires to play again then we reload the level.

Blueprints Visual Scripting for Unreal Engine (Amazon)

Using a Static Camera (UE Docs)

Set View Target with Blend (UE Docs)