The Director’s Chair: Hacking Player Cameras with Verse
The Director's Chair: Hacking Player Cameras with Verse
Ever walk into a room in your Fortnite island and suddenly the player's view snaps to a specific angle, like they're in a movie trailer or a sniper's scope? That's not magic; that's camera hijacking. In UEFN, every player has a "camera stack" — a mental pile of views they're looking through. By default, they're looking through the standard third-person view. But with Verse, you can grab that stack, shove in a new view (like a fixed-angle shot or a dramatic orbit), and make it the active one.
In this tutorial, we're going to build a "Cinematic Trap." When a player steps on a specific zone, their camera gets "locked" into a dramatic, low-angle orbit for 5 seconds, making them feel like the protagonist of an action movie (or a very confused victim). No more accidental camera clipping; you're the director now.
What You'll Learn
- The Camera Stack: Understanding how players switch between normal view, spectate view, and custom cameras.
AddTo: The function that pushes a new camera onto the player's view.RemoveFrom: The function that pops the custom camera off, returning control to the player.- Agent vs. Player: Why we target the "Agent" (the character controller) to change the camera.
How It Works
Think of a player's camera like a stack of playing cards.
- Bottom Card: The default third-person camera. This is always there.
- Middle Card: Maybe a spectate camera if they're dead.
- Top Card: The camera they are currently looking through.
When you want to change what the player sees, you don't delete the bottom card. You just add a new card on top. That new card becomes the "active" view. If you want to stop the custom view, you remove that top card, and the player instantly snaps back to whatever was underneath (usually the default view).
In Verse, this is handled by the AddTo and RemoveFrom functions on camera devices (like FixedAngleCamera or OrbitCamera). These functions take an Agent as an argument. An Agent is just the Verse term for the game character (the player or NPC) that is being controlled.
Let's Build It
We're going to create a simple script that attaches to a Trigger Volume. When a player enters, it grabs a specific Fixed Angle Camera (pre-placed in your level) and forces the player to look through it. After 5 seconds, it releases them.
Prerequisites
- Place a Fixed Angle Camera in your world. Name it
MyCinematicCam. Point it at something cool (a statue, a trap, a loot chest). - Place a Trigger Volume nearby.
- Add a Verse Component to the Trigger Volume.
The Verse Code
# Import the core Verse libraries we need
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
# Define our script component
CinematicTriggerDevice := class(creative_device):
# This is the camera device we dragged into the editor
# note: gameplay_camera_fixed_angle_device is the real Verse type for a Fixed Angle Camera device
@editable
MyCamera : gameplay_camera_fixed_angle_device = gameplay_camera_fixed_angle_device{}
# This is the trigger volume device we dragged into the editor
@editable
MyTrigger : trigger_device = trigger_device{}
# This is the time the camera lock lasts (in seconds)
LockDuration : float = 5.0
# This function runs when the game starts
OnBegin<override>()<suspends> : void =
# Subscribe to the trigger's overlap event so we know when a player enters
MyTrigger.TriggeredEvent.Subscribe(OnTriggered)
# Optional: Log a message to the console to debug
Print("Cinematic Trap Armed!")
# This function runs when something enters the trigger
# trigger_device fires TriggeredEvent with the Agent that activated it
OnTriggered(Agent : ?agent) : void =
# Spawn a concurrent task so the Wait() does not block the event callback
if (A := Agent?):
spawn{ RunCinematic(A) }
# Async helper that locks and then releases the camera for one agent
RunCinematic(Agent : agent)<suspends> : void =
# 1. ADD THE CAMERA
# We are pushing 'MyCamera' onto 'Agent's' camera stack.
# This makes MyCamera the active view.
MyCamera.AddTo(Agent)
# 2. WAIT
# We pause the script for 5 seconds. The player is now stuck looking through our camera.
Sleep(LockDuration)
# 3. REMOVE THE CAMERA
# We pop the camera off the stack. The player returns to normal view.
MyCamera.RemoveFrom(Agent)
Print("Player released from cinematic view!")```
### Walkthrough: What Just Happened?
1. **`MyTrigger.TriggeredEvent.Subscribe(OnTriggered)`**: Instead of overriding a bare overlap function, we subscribe to the trigger device's built-in `TriggeredEvent`. This fires with the `agent` that walked into the volume, which is exactly what we need.
2. **`spawn{ RunCinematic(Agent) }`**: `TriggeredEvent` callbacks must be non-suspending, so we immediately hand off the async work to a new concurrent task. This lets the event handler return instantly while the cinematic logic runs in the background.
3. **`MyCamera.Activate(Agent)`**: This is the magic line. It tells the engine, "Hey Player, stop looking through your default camera. Look through `MyCamera` instead." The player's mouse/controls are now mapped to this new camera's behavior (if it's an orbit camera, they can rotate it; if it's fixed angle, they're locked in).
4. **`Sleep(LockDuration)`**: The script pauses here. The player is stuck. They can't look around normally (depending on camera type). They are at the mercy of the cinematic.
5. **`MyCamera.Deactivate(Agent)`**: This pops the camera off the stack. The player's view snaps back to their standard third-person perspective.
## Try It Yourself
**Challenge:** Make the trap **reversible**.
Right now, the player is stuck for 5 seconds no matter what. Can you modify the script so that if the player presses a specific key (like `Spacebar`) or shoots the camera device, the camera is removed *early*?
*Hint: You'll need to listen for an input event or an overlap with a projectile, then call `Deactivate` immediately. You don't need to wait!*
## Recap
* **Camera Stack:** Players have a stack of cameras. The top one is active.
* **`Activate(Agent)`:** Pushes a new camera onto the stack, hijacking the player's view.
* **`Deactivate(Agent)`:** Pops the camera off, returning control to the player.
* **Scene Graph:** Your camera device is an entity in the world. By linking it to an Agent via Verse, you dynamically change the visual experience without altering the physical world.
Now go make your players feel like the main character. Or at least, like the main character in a very specific, slightly disorienting cutscene.
## References
* https://dev.epicgames.com/documentation/en-us/fortnite/using-orbit-camera-devices-in-fortnite-creative
* https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-fixed-angle-camera-devices-in-fortnite-creative
* https://dev.epicgames.com/documentation/en-us/fortnite/using-fixed-angle-camera-devices-in-fortnite-creative
* https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-fixed-point-camera-devices-in-fortnite-creative
* https://dev.epicgames.com/documentation/en-us/fortnite/using-fixed-point-camera-devices-in-fortnite-creative
Verse source files
- 01-device.verse · device
Turn this into a guided course
Add Adds the camera to the `Agent`'s camera stack and pushes it to be the active camera. 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
- Adds the camera to the `Agent`'s camera stack and pushes it to be the active camera. ↗
- Adds the camera to the `Agent`'s camera stack and pushes it to be the active camera. ↗
- Adds the camera to the `Agent`'s camera stack and pushes it to be the active camera. ↗
- Adds the camera to the `Agent`'s camera stack and pushes it to be the active camera. ↗
- Adds the camera to the `Agent`'s camera stack and pushes it to be the active camera. ↗
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.