tw.camera.free
Side: Client | Aliases: tw.cam, tw.freecam
Interactive freecam system for cinematic camera control. tw.camera.free is callable directly as a shorthand for tw.camera.free.start.
Functions
tw.camera.free.start(options?)
Starts the freecam. This function is blocking — it yields the current thread until the freecam is stopped.
| Parameter | Type | Default | Description |
|---|---|---|---|
options.interpolate | integer? | — | Interpolation duration in ms for smooth camera transition |
options.show_prompts | boolean? | true | Show control prompts on screen |
options.range | number? | 10000 | Maximum distance the camera can travel from start point |
tw.camera.free.start({
interpolate = 500,
show_prompts = true,
range = 5000,
})
-- code here runs after freecam is stoppedtw.camera.free.stop()
Stops the freecam and restores the previous camera state.
tw.camera.free.stop()tw.camera.free.isActive() -> boolean
Returns whether the freecam is currently active.
Returns: boolean
if tw.camera.free.isActive() then
print("Freecam is running")
endtw.camera.free.getCam() -> integer
Returns the camera handle used by the freecam, or -1 if inactive.
Returns: integer — Camera handle or -1
local cam = tw.camera.free.getCam()
if cam ~= -1 then
local pos = GetCamCoord(cam)
endtw.camera.free.lockRotate()
Locks camera rotation. The camera can still move but cannot rotate.
tw.camera.free.lockRotate()tw.camera.free.unlockRotate()
Unlocks camera rotation, restoring full control.
tw.camera.free.unlockRotate()tw.camera.free.isLocked() -> boolean
Returns whether camera rotation is currently locked.
Returns: boolean
if tw.camera.free.isLocked() then
print("Rotation is locked")
endtw.camera.free.getPromptGroup() -> string
Returns the prompt group identifier used by the freecam controls.
Returns: string
ConVars
Speed, rotation sensitivity, and key bindings can be adjusted via ConVars:
| ConVar | Description |
|---|---|
| Speed | Camera movement speed |
| Rotation | Mouse rotation sensitivity |
| Keys | Key bindings for movement and controls |
Examples
Basic freecam with smooth transition
tw.camera.free.start({
interpolate = 1000,
range = 500,
})
-- player regains control here after stoppingCallable shorthand
-- tw.camera.free() is equivalent to tw.camera.free.start()
tw.camera.free({
show_prompts = false,
})Lock rotation for a placement system
tw.camera.free.start({ show_prompts = true })
-- In another thread:
tw.camera.free.lockRotate()
-- Player can only move, not rotate
tw.camera.free.unlockRotate()Notes
tw.camera.free.start()is blocking. Code after the call only executes once the freecam is stopped.tw.camera.free()can be called directly as a function and behaves identically totw.camera.free.start().- The player ped is frozen and invisible while the freecam is active. Previous state is restored on stop.
- The
rangeoption limits how far the camera can travel from the starting point.

