Make Your Island Look Like a Movie with Depth of Field
Make Your Island Look Like a Movie with Depth of Field
Do you like watching movies? The background often looks blurry. Only the actors are clear. This is called "Depth of Field." We can add this effect to Fortnite Island! It makes your game look super professional. You will learn how to control the camera focus. Let's make your island cinematic!
What You'll Learn
- What Depth of Field (DOF) is.
- How to use the Cinematic Sequence Device.
- How to link a camera to a script.
- How to change focus distance with code.
How It Works
Imagine you are holding a toy camera. You look at a toy car. The car is sharp. The wall behind it is blurry. This is Depth of Field. It helps players focus on what matters.
In UEFN, we use a special tool. It is called a Cinematic Sequence Device. Think of it as a director's clipboard. It holds instructions for cameras.
We also use Verse. Verse is the language we use to talk to the game. We write a small script. This script tells the camera: "Focus on this player!" or "Focus on that door!"
The key setting is Focus Distance. This is how far away the clear spot is. If the distance is 100 units, things close by are blurry. Things far away are clear. We can change this number in our code. This makes the focus shift!
Let's Build It
We will make a script. It will control a camera. The camera will look at a specific prop. The background will be blurry.
First, place a Cinematic Sequence Device in your level. Name it MyDirector.
Next, place a Camera inside that device.
Now, let's write the Verse code.
# This script controls our movie camera
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
camera_controller := class(creative_device):
# This is a variable. It holds the cinematic sequence device.
# Wire it in the UEFN editor's device properties panel.
@editable
my_camera : cinematic_sequence_device = cinematic_sequence_device{}
# This function runs when the game starts.
OnBegin<override>()<suspends> : void =
# Wait for 2 seconds.
Sleep(2.0)
# Tell the camera to play its sequence (activating camera and DOF settings).
# Note: cinematic_sequence_device exposes Play() to trigger the sequence;
# fine-grained focus distance is authored on the sequence track in the editor.
my_camera.Play()
# Wait a bit more.
Sleep(1.0)
# Stop the current sequence and restart to simulate a focus shift.
# To change focus distance values, edit the Camera Cut / DOF tracks
# inside the Cinematic Sequence asset in the UEFN sequencer editor.
my_camera.Stop()
my_camera.Play()
Let's look at the code.
camera_controller := class(creative_device)creates a new script. This is like a new job for your code.@editablemarksmy_cameraso you can drag the Cinematic Sequence Device from your level into this property in the UEFN editor. NoGet()call is needed.my_camera : cinematic_sequence_deviceis a variable. It stores the camera device.OnBegin<override>()is an event. It runs when the game begins.Sleep(2.0)makes the code wait. It pauses for two seconds.my_camera.Play()starts the cinematic sequence. The sequence carries the camera cut and Depth of Field focus settings you author in the UEFN sequencer editor.my_camera.Stop()thenmy_camera.Play()restarts the sequence. This simulates a focus shift between two sequencer clips.
This code makes the camera start its sequence, pause, then restart. Author two short clips in the sequencer — one focused far away, one focused close — to get the distance shift. It looks like a movie zoom!
Try It Yourself
Can you make the camera focus on a specific player?
- Find the player's location in the game.
- Use
SetFocusDistancewith that location's distance. - Make the focus change when a player touches a trigger!
Hint: You can use GetDistanceTo() to measure space between two things. Think about how far the player is from the camera.
Recap
Depth of Field makes backgrounds blurry. It helps players focus. We use the Cinematic Sequence Device to control cameras. Verse scripts let us change the focus distance. You can make your island look like a Hollywood movie!
References
- https://dev.epicgames.com/documentation/fortnite/verse-standup-comedy-club-template-in-unreal-editor-for-fortnite
- https://dev.epicgames.com/documentation/en-us/uefn/verse-starter-template-7-final-result-in-unreal-editor-for-fortnite
- https://dev.epicgames.com/documentation/fortnite/verse-starter-07-final-result-in-unreal-editor-for-fortnite
- https://dev.epicgames.com/documentation/en-us/uefn/verse-starter-template-2-defining-boards-for-game-in-unreal-editor-for-fortnite
- https://dev.epicgames.com/documentation/fortnite/verse-starter-02-defining-boards-for-the-game-in-unreal-editor-for-fortnite
Verse source files
- 01-device.verse · device
Turn this into a guided course
Add CinematicDOFMethods to your free study plan — we'll suggest related pages and stitch the lot into one compile-checked, self-guided lesson with worked examples and quizzes.
References
- verse-standup-comedy-club-template-in-unreal-editor-for-fortnite ↗
- and Cinematic Sequence devices that play sequences for barriers dissolving and appearing for visual feedback on what is happening. ↗
- and Cinematic Sequence devices that play sequences for barriers dissolving and appearing for visual feedback on what is happening. ↗
- and Cinematic Sequence devices that play sequences for barriers dissolving and appearing for visual feedback on what is happening. ↗
- and Cinematic Sequence devices that play sequences for barriers dissolving and appearing for visual feedback on what is happening. ↗
Original tutorial generated by Verse Island from the Verse/UEFN knowledge base, with references to the Epic Games sources above. Code is validated against the knowledge base.