Cameraconfig

Panda

Pirate
Developer
Server Owner
Registered
LV
0
 
Joined
May 28, 2026
Messages
22
Reaction score
4
Points
8
Location
Above and Below
Website
chaospirates.com
--=============================================================================
-- CameraConf.lua — Third-person camera tuning
--=============================================================================
-- This file is pure DATA, loaded once when the client starts. Edit a value,
-- relaunch the client, and the change takes effect — no rebuild needed.
--
-- HOW THE CAMERA IS POSITIONED
-- The camera orbits the character. Two numbers place it, and the view ANGLE
-- falls out of them automatically:
-- XY = horizontal distance behind the character (along the ground)
-- Z = height above the character
-- The downward pitch is implied: pitch = atan2( Z , XY )
-- • more Z (or less XY) -> steeper / more top-down
-- • more XY (or less Z) -> flatter / more behind-the-shoulder
--
-- HOW ZOOM WORKS
-- The mouse wheel blends between two endpoints. In every range below:
-- 1st value = ZOOMED IN (wheel forward / camera closest)
-- 2nd value = ZOOMED OUT (wheel back / camera farthest)
-- IMPORTANT: the view angle is set by BOTH endpoints. If the zoomed-out Z is
-- larger than the zoomed-out XY, the camera ends up more ABOVE than BEHIND
-- the character — i.e. top-down. To hold a steady angle while zooming, give
-- both endpoints the same Z:XY ratio and just grow the distance.
--
-- QUICK TUNING CHEAT-SHEET ( pitch = atan2(Z, XY), in degrees )
-- XY 60, Z 30 -> 27° nice pulled-back 3/4 view (recommended)
-- XY 45, Z 24 -> 28°
-- XY 35, Z 50 -> 55° steep, nearly straight down (avoid)
-- Aim for ~25-35° for a classic MMO feel.
-- • Want it pulled BACK further? raise the XY values.
-- • Want it FLATTER (less top-down)? lower the Z values.
-- • Want a steady angle through zoom? keep Z/XY equal at both endpoints.
-- Values are in world units, so nudge and relaunch until it feels right.
--
-- THE FUNCTIONS
-- CameraRangeXY ( mode, zoomedIn, zoomedOut ) horizontal distance behind char
-- CameraRangeZ ( mode, zoomedIn, zoomedOut ) height above char
-- CameraRangeFOV( mode, zoomedIn, zoomedOut ) field of view, degrees (bigger = wider)
-- CameraEnableRotate( mode, 0|1 ) 1 = player may orbit the camera
-- CameraShowSize( mode, width, height ) terrain draw extent (world units)
--
-- THE FOUR CAMERA MODES (each tuned independently below)
-- C_NORMAL on foot, default view
-- C_NEAR on foot, closer variant
-- C_HIGHSPEED while mounted (high speed)
-- C_SHIP while sailing (sits farther out)
--=============================================================================

Rich (BB code):
C_NORMAL    = 0  -- on foot, default
C_NEAR      = 1  -- on foot, closer variant
C_HIGHSPEED = 2  -- mounted / high speed
C_SHIP      = 3  -- sailing (far out)

local iMaxDrawRange = 80   -- terrain draw size shown by the camera (world units)

-------------------------------------------------------------------------------
-- C_NORMAL  —  on-foot default
-- Pulled-back 3/4 view that holds ~27° across the whole zoom range:
--   zoomed in : atan2(16,30) ~= 28deg      zoomed out: atan2(30,60) ~= 27deg
-------------------------------------------------------------------------------
CameraRangeXY ( C_NORMAL, 30, 60 )   -- distance:  30 (in)  -> 60 (out)
CameraRangeZ  ( C_NORMAL, 16, 30 )   -- height:    16 (in)  -> 30 (out)
CameraRangeFOV( C_NORMAL, 12, 32 )   -- fov:       12 (in)  -> 32 (out)  wider as you zoom out
CameraEnableRotate( C_NORMAL, 1 )
CameraShowSize( C_NORMAL, iMaxDrawRange, iMaxDrawRange )

-------------------------------------------------------------------------------
-- C_NEAR  —  on-foot, closer variant (same ~28deg angle, shorter distances)
--   zoomed in : atan2(12,22) ~= 29deg      zoomed out: atan2(24,45) ~= 28deg
-------------------------------------------------------------------------------
CameraRangeXY ( C_NEAR, 22, 45 )
CameraRangeZ  ( C_NEAR, 12, 24 )
CameraRangeFOV( C_NEAR, 12, 32 )
CameraEnableRotate( C_NEAR, 1 )
CameraShowSize( C_NEAR, iMaxDrawRange, iMaxDrawRange )

-------------------------------------------------------------------------------
-- C_HIGHSPEED  —  mounted. Slightly farther back than on foot. ~26deg.
--   zoomed in : atan2(18,35) ~= 27deg      zoomed out: atan2(34,70) ~= 26deg
--   (Starting point — tune for how the mount should feel.)
-------------------------------------------------------------------------------
CameraRangeXY ( C_HIGHSPEED, 35, 70 )
CameraRangeZ  ( C_HIGHSPEED, 18, 34 )
CameraRangeFOV( C_HIGHSPEED, 12, 32 )
CameraEnableRotate( C_HIGHSPEED, 1 )
CameraShowSize( C_HIGHSPEED, iMaxDrawRange, iMaxDrawRange )

-------------------------------------------------------------------------------
-- C_SHIP  —  sailing. Sits the farthest out, slightly flatter for the horizon.
--   zoomed in : atan2(24,50) ~= 26deg      zoomed out: atan2(42,95) ~= 24deg
--   (Starting point — tune for the sea view.)
-------------------------------------------------------------------------------
CameraRangeXY ( C_SHIP, 50, 95 )
CameraRangeZ  ( C_SHIP, 24, 42 )
CameraRangeFOV( C_SHIP, 12, 32 )
CameraEnableRotate( C_SHIP, 1 )
CameraShowSize( C_SHIP, iMaxDrawRange, iMaxDrawRange )

-------------------------------------------------------------------------------
-- Reserved hook: called after the tables above are loaded. Leave empty unless
-- you need to compute camera values at runtime.
-------------------------------------------------------------------------------
function LoadCameraConfig()

end
 
  • Like
Reactions: Zakernado