Skip to main content

BookPageInstance

A class in Root.Township, Alta.Pages.

A page shown inside a book. Grabbing its tip and dragging sideways turns the page, and dragging up or down on a facing page pulls it out or copies it as a paper page. On the page prefab; both sides.

Constructors​

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

Fields​

18 private and internal fields
MemberWhat it is
private Collider[] additionalTightGripCollidersExtra colliders checked when re-evaluating the tight grip on the tip.
private Vector3 basePositionHand position, local to the page, when the tip was grabbed.
private int blendStateHashAnimator state hash for the front or back interacting state, set on grab.
private SoundEffectSet duplicatePageSoundSound played when a page is copied out of the book.
private Transform ghostHandTransformGhost hand of the player holding the tip, tracked each frame.
private int[] gripsToBeLeftHandOnlyOnNotFacingGrab point indexes that refuse the right hand when the page isn't facing.
private int[] gripsToDisableOnNotFacingGrab point indexes turned off when the page isn't facing.
private bool hasActedSet once the current grab has turned, pulled or copied the page, so release does nothing more.
private bool hasActionSoundWhether the pull or copy sound can still play for this grab.
private float horizontalActionReleaseThresholdSideways drag needed at release to turn the page (default 0.1).
private float horizontalActionThresholdSideways drag that turns the page while still holding (default 0.3).
private readonly int horizontalBlendHashAnimator hash of the HorizontalBlend parameter.
private bool isFacingTrue when the grabbed page is the back side (animator's IsFront is false). Only a facing page can be pulled out or copied.
private SoundEffectSet removePageSoundSound played when a page is pulled out of the book.
private Transform rotationEvaluationPoint where a pulled or copied paper page is placed before the grip swaps to it.
private Pickup tipPickupPickup on the page corner that players grab.
private float verticalActionThresholdUp or down drag on a facing page that pulls it out (up) or copies it (down). Default 0.3.
private readonly int verticalBlendHashAnimator hash of the VerticalBlend parameter.

Properties​

MemberWhat it is
bool IsInteractable { get; set; }Whether the page tip can be grabbed. Reads and sets the tip pickup's flag.

Methods​

MemberWhat it is
override void InitializeAsServer(SpawnData spawnData)Server: sets the page animator to always animate so it runs on the headless server.
void Release()Forces whoever holds the tip to drop it.
7 private and internal methods
MemberWhat it is
private void Awake()Hooks the tip pickup's grab, release and hand filter events.
private IEnumerator DelayTurn() (iterator)Coroutine that waits one frame, then turns the book left or right depending on which side was grabbed.
private void FilterHand(Interactor interactor, Interactable interactable, ref bool result)Only lets the tip be grabbed by the player already holding the book.
private void LateUpdate()While the tip is held, tracks the hand and drives the turn blend, page turns and pull-out or copy actions.
private void SwapInteract(Pickup pagePickup)Server: moves the new paper page to the hand and swaps the grip from the tip to that page.
private void TipHeld(Interactable interactable, Interactor interactor)When the tip is grabbed, records the hand's start point, which side is facing, and adjusts which grips are usable.
private void TipReleased(Interactable interactable, Interactor interactor)When the tip is let go without an action, turns the page if dragged past the release threshold (server), else resets the animator.

Used in​

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