Skip to main content

ActionOrb

A class in Root.Township, the global namespace.

A hovering orb the player grabs and pulls to their face to trigger an action, with haptics and a screen fade as it gets closer. Used for menu, revive and server selection orbs.

Constructors​

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

Fields​

13 private and internal fields
MemberWhat it is
private bool canTriggerHapticWhether haptics play; set with SetCanReceiveHapticFeedback.
private PlayerController controllerPlayer controller of whoever last grabbed the orb.
private bool hasScreenFadeWhether bringing the orb to the head fades the screen.
private const string IsMovingKeywordShader keyword turned on while the orb is moving back.
private float minFadeToCountDownTimeFade amount above which the force-join countdown runs.
private Renderer[] renderersToChangeRenderers whose material SetMaterial replaces.
private MaterialInstanceGroup squishableMaterialGroupMaterial instances on the squishable renderers, made on awake and disposed on destroy.
private Renderer[] squishableRenderersRenderers that squish in the direction the orb moves.
private const string SquishDirectionPropertyNameShader property name for the squish direction.
private static readonly int squishDirectionShaderIdShader ID of the squish direction property.
private bool startAtZeroScaleStarts the orb at zero scale so it can grow in.
private float timeToForceJoinSeconds the orb must be held close to the head before it lets go by itself.
private Coroutine updateSelectionOrbThe running UpdateSelectionOrb coroutine, if any.

Events​

MemberWhat it is
event Action OnValidLetGoRaised when the orb is released near the head, or held there long enough to force it.

Methods​

MemberWhat it is
void ResetVelocity()Clears the squish effect.
void SetCanReceiveHapticFeedback(bool canReceiveHaptic)Turns the distance-based controller vibration on or off.
void SetMaterial(Material material)Sets the shared material on the orb's swappable renderers.
protected override void Awake()Creates material instances for the squish effect.
protected override void HandleGrabbed(Interactable interactable, Interactor interactor)Remembers the grabbing player and starts tracking the orb's distance to their head.
protected override void OnDestroy()Disposes the squish material instances.
protected override void OnReturning(Vector3 direction, float velocity)Client: drives the squish shader by the direction and speed the orb flies back.
protected override void Start()Starts the orb at zero scale if set to.
protected override void StartMovingBack(Interactable interactable, Interactor interactor)On release, raises OnValidLetGo if it was let go close enough to the head, else clears the fade.
3 private and internal methods
MemberWhat it is
private void StartScreenFade(float from, float to, float duration)Fades the holder's screen between the given values, if hasScreenFade is on.
private void TriggerHaptic(float strength)Pulses the holding controller at the given strength, unless haptics are turned off.
private IEnumerator UpdateSelectionOrb() (iterator)Coroutine while held: haptics and screen fade grow as the orb nears the head; held close long enough, it lets go and fires OnValidLetGo.

Used in​

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