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.
- Listed in Items, inventory and logic
- Inherits or implements
PageInstance
Constructors
| Member | What it is |
|---|---|
BookPageInstance() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
18 private and internal fields
| Member | What it is |
|---|---|
private Collider[] additionalTightGripColliders | Extra colliders checked when re-evaluating the tight grip on the tip. |
private Vector3 basePosition | Hand position, local to the page, when the tip was grabbed. |
private int blendStateHash | Animator state hash for the front or back interacting state, set on grab. |
private SoundEffectSet duplicatePageSound | Sound played when a page is copied out of the book. |
private Transform ghostHandTransform | Ghost hand of the player holding the tip, tracked each frame. |
private int[] gripsToBeLeftHandOnlyOnNotFacing | Grab point indexes that refuse the right hand when the page isn't facing. |
private int[] gripsToDisableOnNotFacing | Grab point indexes turned off when the page isn't facing. |
private bool hasActed | Set once the current grab has turned, pulled or copied the page, so release does nothing more. |
private bool hasActionSound | Whether the pull or copy sound can still play for this grab. |
private float horizontalActionReleaseThreshold | Sideways drag needed at release to turn the page (default 0.1). |
private float horizontalActionThreshold | Sideways drag that turns the page while still holding (default 0.3). |
private readonly int horizontalBlendHash | Animator hash of the HorizontalBlend parameter. |
private bool isFacing | True 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 removePageSound | Sound played when a page is pulled out of the book. |
private Transform rotationEvaluation | Point where a pulled or copied paper page is placed before the grip swaps to it. |
private Pickup tipPickup | Pickup on the page corner that players grab. |
private float verticalActionThreshold | Up or down drag on a facing page that pulls it out (up) or copies it (down). Default 0.3. |
private readonly int verticalBlendHash | Animator hash of the VerticalBlend parameter. |
Properties
| Member | What it is |
|---|---|
bool IsInteractable { get; set; } | Whether the page tip can be grabbed. Reads and sets the tip pickup's flag. |
Methods
| Member | What 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
| Member | What 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: