Skip to main content

CastToSurfaceEffect

A class in Root.Township, the global namespace.

Pooled effect (a DestroyByTime) that, when taken from the pool, line-casts for ground and shows a child particle at the hit point, facing along the surface normal.

Constructors​

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

Fields​

5 private and internal fields
MemberWhat it is
private Vector3 castDirectionDirection of the cast. Default down.
private float castDistanceLength of the cast, centred on the effect's position.
private LayerMask groundLayersLayers the cast can hit.
private GameObject groundParticleChild object shown at the ground hit point.
private bool isCastingSet at bake time when groundParticle is set. Nothing happens at runtime when false.

Methods​

MemberWhat it is
protected override void Awake()If baking found a ground particle, hides it and hooks the pool request and release events.
3 private and internal methods
MemberWhat it is
private void CastToGround(PooledObject pooledObject)On pool request: casts along castDirection and, on a hit, moves and shows the ground particle there.
private void IBuildRendererPostBake.PostBake()Build bake step: sets isCasting to whether a ground particle is assigned.
private void StoreCasted(PooledObject pooledObject)On pool release: hides the ground particle.