sunfall.package
This package holds more than this page lists. See all of its files in its world.
README.md
GliderCamera
Sunfall Ridge's chase camera for a pilot under a glider: a camera behaviour (tagged
cameraBehavior) set as the behavior of the Camera on the player prototype's camera rig,
with Camera.follow bound to the pilot's body as every follow camera is. The body needs
glideKit's Glider and airMotor's controller (the CharacterController the player prototype
already carries).
What it does
- In the air it rides 8 m behind and 2.2 m above the pilot's hips along the flight path (the body's velocity), framed so the pilot sits in the lower-middle third and the horizon, the low sun and the ridge stay in the picture.
- Every part of the framing (heading, distance, height, roll, field of view) moves on critically damped springs: no jitter, no snap in a turn, a dive or a landing.
- Turns: the turn rate is fed forward so the camera holds station behind the wing in a
steady turn; it swings a little to the inside of the turn while its aim leads into it
(
turnSwing,maxSwing), and it rolls withbankShare(40%) of the glider's bank. - Speed: it pulls back (
speedPullBack) and widens its field of view fromfovSlow(58° at 12 m/s) tofovFast(68° at 30 m/s). Dive: it rises (diveRise) and tips its aim down (diveTilt) so the ground ahead shows. - Clearance: it stays
groundClearanceabove the terrain (theTerrainof the entity namedterrainName,ridgeby default, throughheightAt; a downward ray where there is none), and a ray from the pilot pulls it in ahead of any collider; it never comes closer than a style's minimum distance, so it stays outside the wing. - Look around: the look control of the Controllers library's
cameraRigmap (right-button drag, right stick, right-side touch drag) turns it round the pilot withinlookYawLimit(±70°) in the air, and it eases back afterlookReturnDelay(1 s) without input. - On the ground (landed or walking) it settles into a calm third-person orbit
(
groundDistance,groundHeight), behind a walking pilot and drifting slowly round one who stands (groundDrift); the look control orbits it freely. - Styles: each glider style has a framing profile. A canopy (paraglider, umbrella, leaf) is framed from lower and further back so the canopy reads as a shape overhead.
Setup
local rig = entity.spawn("CameraRig", { parent = prototype })
rig:setNetworkScope("OwnerOnly")
rig.component.add("Camera", { behavior = asset.resolve("sunfall.GliderCamera", "component"), fov = 60 })
body.component.add("Glider", { style = "hangGlider", cameraFollow = false, cameraFx = false })
It owns the camera's transform and field of view, so the Glider's cameraFollow and
cameraFx must be off (glideKit's FOV kick and its orbital easing would fight it).
framingState() reads the framing it holds now (heading, turn rate, roll, field of view,
distance, height, look offsets, how far it reads the pilot as flying).