FlyCameraController class Scene graph

A free-look flying camera: drag to look, WASD to move on the look plane (strafing ignores pitch so looking down does not drift into the floor), Q/E to move down/up, and shift to boost speed.

Yaw and a pitch clamped short of vertical drive the view, with roll pinned level, so it never rolls or flips over the poles. Set moveVertical false for a grounded first-person camera: Q/E are ignored and forward/back stays horizontal.

Attach it to a node that also carries a CameraComponent. Drive it with a CameraControls widget, or call look and set the move keys directly.

Inheritance

Constructors

FlyCameraController({Vector3? position, double yaw = 0.0, double pitch = 0.0, double speed = 5.0, double boostMultiplier = 4.0, double lookSensitivity = 0.005, double movementSmoothing = 0.0, bool moveVertical = true, double pitchLimit = _defaultPitchLimit, double smoothing = 0.0})
Creates a fly controller starting at position with the given yaw and pitch (radians).

Properties

boostMultiplier double
Speed multiplier while shift is held.
getter/setter pair
enabled bool
Whether this component's update hook runs each frame.
getter/setter pairinherited
forward → Vector3
The unit look direction. At yaw 0, pitch 0 this is (0, 0, -1).
no setter
hashCode int
The hash code for this object.
no setterinherited
isAttached bool
Whether this component is currently attached to a node.
no setterinherited
isLoaded bool
Whether onLoad has completed.
no setterinherited
isMounted bool
Whether the owning node is part of a live scene graph.
no setterinherited
lookSensitivity double
Radians of look per logical pixel of drag.
getter/setter pair
movementSmoothing double
Settle time in seconds for the velocity easing (0 moves instantly).
getter/setter pair
moveVertical bool
Whether Q/E move vertically and forward/back follows pitch. When false the camera is grounded (first-person): Q/E ignored, forward/back stays level.
getter/setter pair
node Node
The node this component is attached to.
no setterinherited
pitchLimit double
Maximum pitch magnitude (radians), kept short of vertical.
getter/setter pair
position ↔ Vector3
World-space eye position.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
smoothing double
Approximate time in seconds to settle after input stops (reach ~1% of the remaining offset). Zero moves instantly with no easing.
getter/setter pairinherited
speed double
Movement speed, world units per second.
getter/setter pair
viewportSize Size
The size of the view driving this controller, in logical pixels.
getter/setter pairinherited

Methods

clampDeltaSeconds(double deltaSeconds) double
Clamps a frame delta so a stall or a paused view does not teleport the camera when it resumes.
inherited
cloneFor(Node cloneOwner) Component?
Returns a copy of this component for cloneOwner, the Node.clone counterpart of the owning node, or null to not carry the component to clones (the default).
inherited
fixedUpdate(double fixedDt) → void
Called once per fixed physics step while the component is mounted, enabled, and loaded. fixedDt is the fixed timestep of the surrounding PhysicsWorld, not the frame interval.
inherited
handleDragUpdate(Offset delta) → void
A primary drag (one finger, or a left-button mouse drag), in logical pixels. The default rotates/looks; override to remap.
override
handleKeyEvent(KeyEvent event) bool
A keyboard event; controllers that move on keys track held state here. Returns true when the key is consumed (so the driver can stop it propagating and the platform does not beep at a held movement key).
override
handleScaleUpdate(double scaleFactor, Offset focalDelta) → void
A two-plus finger gesture: scaleFactor is the incremental pinch factor since the last update (>1 spreading, <1 pinching) and focalDelta is the centroid movement in logical pixels.
inherited
handleScroll(double scrollDelta) → void
A scroll/wheel notch; scrollDelta follows the platform sign (positive scrolling down/away).
inherited
handleSecondaryDragUpdate(Offset delta) → void
A secondary drag (right-button mouse drag), in logical pixels. The default pans where the controller supports it.
inherited
look(Offset delta) → void
Rotates the view by a drag delta (logical pixels). Horizontal drags turn, vertical drags pitch (clamped short of vertical).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onAttach() → void
Called when this component is added to a node.
inherited
onDetach() → void
Called when this component is removed from a node.
inherited
onLoad() Future<void>
Optional asynchronous setup, such as loading an asset.
inherited
onMount() → void
Called when the owning node enters a live scene graph.
inherited
onUnmount() → void
Called when the owning node leaves a live scene graph.
inherited
releaseInput() → void
Releases any held input (call when the driving view loses focus so keys released elsewhere do not stick).
override
settleResponse(double smoothingSeconds, double deltaSeconds) double
smoothingResponse for an explicit smoothingSeconds, so a controller can settle different quantities (look versus movement) at different rates.
inherited
smoothingResponse(double deltaSeconds) double
The fraction of the remaining offset to consume this frame for a frame-rate independent exponential settle. One when smoothing is zero.
inherited
toString() String
A string representation of this object.
inherited
update(double deltaSeconds) → void
Called once per frame while the component is mounted, enabled, and loaded. deltaSeconds is the elapsed time since the previous tick. A traversal visits each component at most once. Removing this component or an earlier sibling is safe. A component inserted before the current traversal position starts on the next frame. Reordering component or child lists during traversal is unsupported.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

moveKeys Set<LogicalKeyboardKey>
The movement keys this controller consumes.
final