Skip to main content

GhostSnapObject

A class in Root.Township, the global namespace.

An item that shows a ghost preview at a matching GhostSnapSlot while held, and snaps into it when let go. The server does the snap.

Constructors​

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

Fields​

3 private and internal fields
MemberWhat it is
private GhostSnapChannel channelWhich ghost snap channel this object belongs to; slots only take matching objects. Backing field for Channel.
private GameObject ghostVersionThe see-through preview object shown at a slot while the item is held near it.
private uint parentSlotIndexIndex of the slot this object is snapped to. Backing field for ParentSlotIndex.

Properties​

MemberWhat it is
GhostSnapChannel Channel { get; }Slots only accept objects whose channel they list.
GhostSnapSlot GhostShownAt { get; protected set; }Slot the ghost is shown at, or null.
uint ParentSlotIndex { get; set; }Index of the slot it is snapped into, set by the slot.
Pickup Pickup { get; }This entity's Pickup.
Rigidbody Rigidbody { get; }The pickup's rigidbody. Made kinematic when snapped.

Methods​

MemberWhat it is
void HideGhost()Clears the slot and hides the ghost.
void ShowGhost(GhostSnapSlot target)Remembers the slot and, while held, shows the ghost copy there.
5 private and internal methods
MemberWhat it is
private void Awake()Hides the ghost and hooks the pickup's grab and release events.
private bool EnsureGhost()Creates the ghost from the prefab's ghostVersion if this copy has none; logs an error if the prefab has none either.
private void InteractionEnded(Interactable interactable, Interactor interactor)When the last hand lets go while a ghost is shown, the server tries to snap the object to that slot; the ghost is hidden.
private void InteractionStarted(Interactable interactable, Interactor interactor)Shows the ghost again at the current slot when the object is picked up.
private void OnDestroy()Destroys the ghost object.

Used in​

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