Skip to main content

ExplosionRadius

A class in Root.Township, the global namespace.

Visual for an explosion's radius: it unparents itself while enabled, follows its original parent and scales a child to the radius, destroying itself if the parent is gone.

Constructors​

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

Fields​

4 private and internal fields
MemberWhat it is
private Transform cachedParentOriginal parent.
private float explosionRadiusRadius to show.
private float scaleMultiplierScale per unit of radius, to match the mesh size.
private Transform scalerTransform scaled to show the radius.

Methods​

5 private and internal methods
MemberWhat it is
private void Awake()Remembers the original parent.
private IEnumerator FixParent() (iterator)A frame after disabling, reparents to the original parent or destroys itself if that is gone.
private void LateUpdate()Follows the parent's position and scales scaler to explosionRadius times scaleMultiplier.
private void OnDisable()Starts FixParent.
private void OnEnable()Unparents itself.