PlayerLocomotionController
A class in Root.Township, the global namespace.
The VR body's LocomotionController: adds teleport styles (instant, lerp, fade), combat steps and smoothing of remote bodies. Get it from PlayerCharacter.LocomotionController.
- Listed in Global namespace: P
- Inherits or implements
LocomotionController,INetworkSerialized - Nested types
SmoothingSetting - Documented in Locomotion
Constructors
| Member | What it is |
|---|---|
PlayerLocomotionController() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
19 private and internal fields
| Member | What it is |
|---|---|
private Coroutine currentTranslate | Running LerpPosition coroutine, stopped when a new teleport starts. |
private LayerMask dashBlockageMask | Layers that block a combat step. |
private float dashCooldown | Seconds between combat steps. Defaults to 0.5. |
private LayerMask dashStandableMask | Layers a combat step can land on. |
private int halfSteps | How many times a blocked step is retried at half the distance. |
private bool isUsingTrail | Whether moves show a teleport trail. Set from the remote trail sync. |
private float lerpDuration | Duration of the combat step move. Zero uses the default teleport duration. |
private static readonly Logger logger | NLog logger for this class. |
private float maximumFall | How far down a combat step looks for ground. |
private float maxStepAngle | Steepest surface, in degrees, a combat step can land on. |
private Transform origin | Transform whose rotation turns stick input into a step direction (the player camera). |
private static readonly AccumulativeAverageCount prepareForWriteTimer | Static backing field for the explicit PrepareForWriteTimer. |
private MethodSyncStruct<bool> remoteTrailMovement | Method sync on EffectRequest for the trail flag. |
private static readonly AccumulativeAverageCount serializeTimer | Static backing field for the explicit SerializeTimer. |
private PlayerLocomotionController.SmoothingSetting[] smoothingSettings | Locomotion and transform lerp pairs, one per PlayerSmoothManager setting index. |
private NetworkTransform[] smoothTransforms | Network transforms whose lerp is set by the smoothing setting. |
private float stepVelocity | Distance of a full combat step. Defaults to 0.6. |
private LocomotionStyle style | Teleport style used for combat steps. Defaults to Lerp. |
private Vector3 translateVelocity | Smooth-damp velocity used by LerpPosition. |
Properties
| Member | What it is |
|---|---|
Vector3 BodyPosition { get; set; } | Where the body target was when a trail teleport started. |
bool IsOnCooldown { get; set; } | True while a combat step is cooling down. |
protected PlayerCharacter PlayerController { get; } | The body as a PlayerCharacter. |
2 private and internal properties
| Member | What it is |
|---|---|
private AccumulativeAverageCount Alta.Networking.INetworkSerialized.PrepareForWriteTimer { get; } | Shared timing stats for preparing player locomotion writes. |
private AccumulativeAverageCount Alta.Networking.INetworkSerialized.SerializeTimer { get; } | Shared timing stats for serializing player locomotion. |
Methods
| Member | What it is |
|---|---|
override void Initialize() | Sets up the trail message and applies the player smoothing setting. |
override void MoveTo(Vector3 position, LocomotionFunction function) | Moves the feet to a position. On the owner it teleports; on any other side it sends the move to the owning player. |
override void RotateAroundPlayer(Quaternion rotation, LocomotionStyle teleportStyle, float duration) | Turns the body while keeping the player's real feet in place. |
void TeleportTo(Vector3 position, TeleportMode mode, LocomotionFunction function, bool isUsingTrail = false) | Moves the body with a style and duration. Fade goes to black and back; lerp smooths there first. Can show a trail to others. |
void TeleportTo(Vector3 position, TeleportMode mode, LocomotionStyle style, LocomotionFunction function, float duration = 0.02, bool isUsingTrail = false) | Moves the body with a style and duration. Fade goes to black and back; lerp smooths there first. Can show a trail to others. |
void TryStep(PlayerInput controller) | Combat step: tries a short hop in the stick direction onto standable ground, then starts the cooldown. |
protected override void InternalFaceTowardsXZ(Vector3 forward) | Rotates the body around the player so the head faces a flat direction. |
protected override void OnEnable() | Hooks the teleport arrive sound on clients. |
9 private and internal methods
| Member | What it is |
|---|---|
private IEnumerator LerpPosition(Vector3 target, float duration, Action lerpFinishedCallback) (iterator) | Coroutine that smooth-damps the local position to a target, then runs a callback. Used by Lerp-style teleports. |
private IEnumerator LerpRotation(Quaternion rotation, float duration) (iterator) | Coroutine that slerps the rotation to a target. Not called in this class. |
private void OnDestroy() | Unhooks from PlayerSmoothManager.SettingChanged. |
private void OnDisable() | Client: unhooks the teleport arrival sound. |
private void RemoteTrailMovement(IPlayer player, Stream stream, bool isUsingTrail) | Method sync for whether the last move used a teleport trail. The server relays it to everyone else. |
private IEnumerator RunStepCoolDown() (iterator) | Waits dashCooldown, then steps again if a Step action is still held, otherwise clears IsOnCooldown. |
private bool SetupOrigin() | Editor helper: sets origin to the player camera. |
private void TeleportFinishedSound(PlayerController player, Vector3 oldPosition, Vector3 newPosition, LocomotionFunction function) | Client: plays the teleport arrive sound after a teleport-locomotion move. |
private void UpdateSmoothing(int smoothingLevel) | Applies the smoothing setting at the chosen index to the locomotion lerp and the smoothed network transforms. |
Used in
Members of other types that take, return or hold a PlayerLocomotionController: