Skip to main content

Scene Capture

The SceneCapture module provides a simple interface for creating scene capture components that render the game world to render targets. This is useful for creating security cameras, mirrors, portals, picture-in-picture effects, and more.

/// tip SceneCapture wraps an AActor, so you can access actor functions through the .Object property ///

Constructor

Example
local myCapture = SceneCapture(
Vector(0, 0, 500),
Rotator(-45, 0, 0),
1920,
1080,
SceneCaptureSource.FinalColorLDR,
false
)
NameTypeDefaultDescription
LocationVector(0, 0, 0)World position for the capture camera
RotationRotator(0, 0, 0)World orientation for the capture camera
Widthnumber1920Render target width in pixels
Heightnumber1080Render target height in pixels
CaptureSourceenumFinalColorLDRWhat the camera captures (see Capture Sources below)
bFollowPlayerbooleanfalseWhether to automatically follow the player's camera

Properties

PropertyTypeDescription
ObjectAActorThe spawned actor containing the capture component
ComponentUSceneCaptureComponent2DThe scene capture component
RenderTargetUTextureRenderTarget2DThe render target texture being rendered to
UpdateTimerTimerInternal timer used for player camera following

Functions

FollowPlayerCamera

Makes the scene capture automatically follow the player's camera position and rotation.

  • updateInterval: number — Update frequency in milliseconds (default: 16ms for ~60fps)
Example
myCapture:FollowPlayerCamera(16)  -- Follow at 60fps
myCapture:FollowPlayerCamera(33) -- Follow at ~30fps

StopFollowing

Stops the scene capture from following the player camera.

Example
myCapture:StopFollowing()

SetTransform

Sets the world position and rotation of the scene capture.

  • location: Vector — New world position
  • rotation: Rotator — New world orientation
Example
myCapture:SetTransform(
Vector(1000, 0, 500),
Rotator(-30, 90, 0)
)

Usage Examples

Fixed Security Camera

Example
local securityCamera = SceneCapture(
Vector(0, 0, 500), -- High up
Rotator(-45, 0, 0), -- Looking down
1280, -- 720p resolution
720
)

-- Use the render target in a material or UI
local renderTarget = securityCamera.RenderTarget

Player Camera Mirror

Example
local mirror = SceneCapture(
nil, -- Location (will use player camera)
nil, -- Rotation (will use player camera)
1920, -- Full HD
1080,
SceneCaptureSource.FinalColorLDR,
true -- Auto-follow player
)

Picture-in-Picture Effect

Example
local pip = SceneCapture(
Vector(0, -500, 200), -- Behind player
Rotator(0, 0, 0), -- Forward facing
640, -- Small resolution
360
)

-- Display the render target in a UI widget

Custom Follow Behavior

Example
local capture = SceneCapture(
Vector(0, 0, 300),
Rotator(0, 0, 0),
1920,
1080
)

-- Start following at 30fps
capture:FollowPlayerCamera(33)

-- Later, stop and set custom position
capture:StopFollowing()
capture:SetTransform(
Vector(500, 500, 600),
Rotator(-60, 45, 0)
)

Depth Camera for Post-Processing

Example
local depthCapture = SceneCapture(
Vector(0, 0, 200),
Rotator(0, 0, 0),
1920,
1080,
SceneCaptureSource.SceneDepth, -- Capture depth
false
)

-- Use depth render target for custom effects
local depthRT = depthCapture.RenderTarget