Skip to main content

EnableAndUnchildIfClose

A class in Root.Township, the global namespace.

Client effect helper: when triggered near the local player, unparents and enables its object, then destroys it after a delay.

Constructors​

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

Fields​

2 private and internal fields
MemberWhat it is
private float destroyAfterSeconds before the object is destroyed; 0 or less keeps it.
private float distanceSquaredSquared distance from the local player within which it triggers.

Methods​

MemberWhat it is
void Trigger()Does nothing on a headless server or if the local player is too far; otherwise unparents, enables and schedules destruction.