Skip to main content

ThrowAlignHelper

A class in Root.Township, the global namespace.

Throwable pickup behaviour that adds torque on throw to turn a chosen local axis towards the throw direction, so things like spears fly point first.

Constructors​

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

Fields​

4 private and internal fields
MemberWhat it is
private Vector3 throwAlignToLocal axis that should point along the throw.
private Vector3 torqueCurrent blended torque.
private float torqueLerpHow fast the torque blends towards the target, scaled by throw strength.
private float torqueMultiplierScale on the applied torque.

Methods​

MemberWhat it is
protected override void ResetValues()Clears the stored torque.
protected override void ThrowBehaviour(Vector3 velocity, float throwMagnitude)Works out the torque needed to turn throwAlignTo onto the velocity, blends it by throw strength and applies it as an impulse.
1 private and internal method
MemberWhat it is
private void OnDrawGizmosSelected()Draws the align axis as a blue line.