Skip to main content

DepthCheckLocoCheck

A class in Root.Township, the global namespace.

Locomotion modifier check asset that works out how deep a smooth-locomotion player stands in a volume (for example water) and runs shallow or deep actions. It can also block teleporting into a given depth.

Constructors​

MemberWhat it is
DepthCheckLocoCheck()Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets.

Fields​

11 private and internal fields
MemberWhat it is
private Dictionary<SmoothLocomotionPlayerController, DepthCheckLocoCheck.ModifierCheck> checkingPlayersPlayers inside the volume and their current depth.
private LocomotionModifierAction[] deepActionsActions run while the player is deep.
private float heightModifierForDepthShare of the player's capsule height at which shallow becomes deep.
private bool isRaycastingWhether to find the surface by raycasting down instead of using the volume's top.
private float minDepthDepth below which the player counts as out.
private float raycastHeightHow far above the feet the raycast starts.
private LayerMask raycastMaskLayers the surface raycast hits.
private LocomotionModifierAction[] shallowActionsActions run while the player is shallow.
private DepthCheckLocoCheck.Depth teleportBlockDepths that teleporting into is blocked for.
private static UpdateModule updateModuleShared fixed-update module the check runs in.
private IUnityUpdateMethod updatePositionsRegistration of UpdatePositions, removed when no players are tracked.

Methods​

MemberWhat it is
override void Enter(SmoothLocomotionPlayerController player, Bounds bounds)Starts tracking a player who entered the volume, with the volume's top as the surface.
override bool IsValidTeleportationPosition(Vector3 position, PlayerController playerController, Bounds bounds)Returns false if the target spot is at a depth listed in teleportBlock.
override void Leave(SmoothLocomotionPlayerController player, Bounds bounds)Stops tracking the player and finishes their current depth's actions.
5 private and internal methods
MemberWhat it is
private void EnterDepth(DepthCheckLocoCheck.Depth depth, SmoothLocomotionPlayerController player)Begins the shallow or deep actions for the player.
private DepthCheckLocoCheck.Depth GetDepth(SmoothLocomotionPlayerController player, float surface)Gets the player's depth below the surface (or a raycast hit): out, shallow, or deep past a share of their height.
private DepthCheckLocoCheck.Depth GetDepth(Vector3 position, SmoothLocomotionPlayerController player, float surface)Gets the player's depth below the surface (or a raycast hit): out, shallow, or deep past a share of their height.
private void LeaveDepth(DepthCheckLocoCheck.Depth depth, SmoothLocomotionPlayerController player)Finishes the shallow or deep actions for the player.
private void UpdatePositions()Each fixed update, switches actions for any tracked player whose depth changed.