Skip to main content

DropTarget

A class in Root.Township, the global namespace.

Snap point for one specific pickup: fades a ghost in as it gets close, then locks it in place and fires events when it is near enough and lined up.

Constructors​

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

Fields​

10 private and internal fields
MemberWhat it is
private Color colorOriginal ghost colour; its alpha is the maximum fade.
private Pickup droppableThe pickup that can snap here; cleared once it has.
private UnityEvent droppedDelayedEvent fired eventDelay seconds after the snap.
private UnityEvent droppedImmediateEvent fired as soon as the pickup snaps.
private float eventDelaySeconds before droppedDelayed fires.
private MeshRenderer ghostOptional renderer that shows where the pickup goes.
private float ghostDistanceDistance at which the ghost starts to fade in.
private Material ghostMaterialInstance of the ghost material whose alpha is changed.
private float snapAngleLargest rotation difference in degrees that still snaps.
private float snapDistanceDistance at which the pickup snaps.

Methods​

4 private and internal methods
MemberWhat it is
private IEnumerator CallDelayed() (iterator)Coroutine that waits eventDelay seconds and then fires droppedDelayed.
private void FixedUpdate()Fades the ghost by distance and, inside the snap distance and angle, force-drops the pickup and parents it here frozen and non-interactable.
private void OnDestroy()Cleans up the ghost material copy.
private void Start()Takes a tracked copy of the ghost material and remembers its colour.