Skip to main content

FlyCamLocomotionController

A class in Root.Township, the global namespace.

Moves the fly cam from keyboard, mouse and gamepad, with optional cinematic smoothing, and handles its hotkeys. Movement runs on the local player and is streamed.

Constructors​

MemberWhat it is
FlyCamLocomotionController()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

16 private and internal fields
MemberWhat it is
private TeleporterTrailLerper activeTrailTrail currently shown to other players.
private MethodSync changeSensesMethod sync sent by ; or d-pad down to cycle senses.
private FlyCamInput flyCamInputFly cam input actions, local player only.
private QuickAccessMenuAction micMuteActionQuick action run by M.
private QuickAccessMenuAction modsMicMuteActionQuick action run by Shift+M.
private bool pressedDownEdge state for d-pad down.
private bool pressedSidesEdge state for d-pad left and right (sensitivity change).
private bool pressedUpEdge state for d-pad up (cinematic toggle).
private int selectedDirectionGamepad stick-click speed mode: 1 fast, -1 slow, 0 normal.
private int senseIndexIndex of the current sense setup.
private FlyCamLocomotionController.SenseSetupSet[] senseSetupsSense setups cycled by ChangeSense.
private QuickAccessMenuAction showNamesActionQuick action run by N.
private Vector3 smoothInputMovementSmoothed move input for cinematic mode.
private Vector2 smoothInputRotationSmoothed look input for cinematic mode.
private Target targetAI target registered only while the fly cam is set as alive.
private PooledObjectDefinition trailPooled trail shown to other players when the fly cam is visible.

Properties​

MemberWhat it is
protected FlyCamPlayer PlayerController { get; }The owning FlyCamPlayer.

Methods​

MemberWhat it is
override void Initialize()Turns on streaming and sets up the sense change sync.
override void InitializeAsServer(SpawnData spawnData)Server: applies the current sense setup to the fly cam's AI target.
protected override void Update()Local player: reads look, move and climb input, applies speed modifiers and smoothing, and handles d-pad and key shortcuts.
7 private and internal methods
MemberWhat it is
private void ChangeSense(IPlayer player, Stream stream)Sync handler: cycles to the next sense setup and toggles whether AI can target the fly cam.
private void CleanTrail(NetworkEntity entity, bool isUnload)Releases the trail when the entity is destroyed by the scene.
private bool GetKey(Key key)True while a keyboard key is held. False with no keyboard.
private bool GetKeyDown(Key key)True on the frame a keyboard key is pressed. False with no keyboard.
private void OnValidate()Fixes up every sense setup in the inspector.
private void Start()Marks the fly cam not alive and hidden from AI; sets up input on the local player or the trail for remote viewers.
private void UpdateVisibility(bool isVisible)Remote clients: shows or removes the trail when the fly cam's visibility changes.