Skip to main content

EmbeddableSurface

A class in Root.Township, Alta.Impact.

Lets tools stick into a surface: a hard enough hit wedges the tool in with a spring joint until it is pulled out past breakDistance.

Constructors​

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

Fields​

6 private and internal fields
MemberWhat it is
private float breakDistanceHow far the tool must be pulled back before it comes free.
private float damperDamper on the joint's spring.
private ImpactDetector detectorThe impact detector on this object.
private float minimumDamageLowest health damage that makes the tool stick.
private AnimationCurve springJoint spring strength by distance pulled out.
private float wedgeDistanceHow far the tool is pushed in along the hit direction.

Methods​

4 private and internal methods
MemberWhat it is
private IEnumerator CheckBreak(ImpactHitWithTool impact, ConfigurableJoint joint, Pickup pickup) (iterator)Coroutine that adjusts the joint spring as the tool is pulled and removes the joint once pulled out past breakDistance.
private void Hit(ImpactHit rawImpact)On a hit above minimumDamage, snaps the tool in slightly and joins it to what it struck.
private void OnDisable()Unhooks the detector's Hit event.
private void OnEnable()Hooks the detector's Hit event.