Skip to main content

RoomRotator

A class in Root.Township, the global namespace.

Controller extension that turns the local VR player with snap or smooth rotation, following the turn settings. Client only; one per hand controller.

Constructors​

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

Fields​

13 private and internal fields
MemberWhat it is
private float currentMultiplierSmooth turn speed multiplier picked from the speed setting.
private float currentSensitivitySwipe sensitivity multiplier picked from the settings.
private bool isClockwiseDirection for RotateJustVRControls. Flipped for the left hand.
private bool isOnReleaseWhen true, snap turns happen on button release rather than press.
private bool isRotatingAroundPlayerNotRoomWhen true, turns around the player's position; otherwise uses the locomotion controller's plain RotateTo.
private bool isUsingPlayerTeleportSettingsWhen true, the turn uses the player's teleport style (fade or lerp) instead of instant.
private PlayerController playerControllerThe player controller being turned.
private float rotationAmountSnap turn angle in degrees. Defaults to 90.
private float[] sensitivityMultiplierMultipliers for the four swipe sensitivity levels.
private AnimationCurve smoothRotationSpeedCurve from input to turn speed for smooth turning.
private float[] smoothRotationSpeedMultiplierMultipliers for the four smooth turn speed settings.
private IUnityUpdateMethod updateHandle for the registered smooth turn update.
private static UpdateModule updateModuleShared update module all room rotators register their smooth turn with.

Methods​

MemberWhat it is
protected override void Awake()Finds the player controller, flips direction for the left hand and listens for settings changes.
18 private and internal methods
MemberWhat it is
private void CheckSettings(Settings obj)Re-applies the turn mode when game settings change, if enabled.
private void Disable()Unhooks all turn actions and the smooth turn update.
private void Enable()Hooks snap turn actions or a smooth turn update to match the settings, and reads speed and swipe sensitivity.
private void OnDestroy()Stops listening for settings changes.
private void OnDisable()Stops listening for new controllers and unhooks all turning.
private void OnEnable()Listens for the controller arriving and sets up turning once it has.
private void ProcessInput(float input)Smooth turn step: scales the input, runs it through the speed curve and turns, if the hand is free.
private void RotateJustVRControls(PlayerInput controller)Turns the play space by rotationAmount while putting the body back where it was.
private void RotateJustVRControls(PlayerInput controller, bool isDisabling)Turns the play space by rotationAmount while putting the body back where it was.
private void RotateRoom(int direction, float rotationAmount)Turns the player by an angle around the player (or the room), unless locomotion is blocked.
private void RotateRoomLeft(PlayerInput controller)Snap turns left by rotationAmount if the hand is free.
private void RotateRoomLeft(PlayerInput playerInput, bool isDisabling)Snap turns left by rotationAmount if the hand is free.
private void RotateRoomRight(PlayerInput controller)Snap turns right by rotationAmount if the hand is free.
private void RotateRoomRight(PlayerInput controller, bool isDisabling)Snap turns right by rotationAmount if the hand is free.
private void RotateRoomSwipe(PlayerInput playerInput)Snap turns in the swipe direction on OpenXR controllers with a swipe pad.
private void ThumbstickSmoothRotation()Per-frame smooth turn from the left and right turn actions, scaled by stick amount.
private void TouchPadSmoothRotation()Per-frame smooth turn from the swipe pad while it is touched.
private void UpdateController(PlayerInput input)Calls Enable a frame later when a new controller is received.

Used in​

Members of other types that take, return or hold a RoomRotator: