Skip to main content

Gear

A class in Root.Township, the global namespace.

A 2D gear on a Turnable chain that snaps to meshing gears nearby and lines up its teeth with them. Probably an editor or prototype tool.

Constructors​

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

Fields​

3 private and internal fields
MemberWhat it is
private Collider2D[] colliderCheckReused buffer for the 2D overlap check.
private Vector3 oldPositionUnused.
private int teethBacking field for Teeth.

Properties​

MemberWhat it is
int Teeth { get; }Number of teeth, used for the turn ratio.

Methods​

MemberWhat it is
void AlignWith(Gear other)Meant to align with another gear; computes a plane intersection but applies nothing.
void UpdateConnected()Finds gears touching by radius, connects them and moves and rotates this gear to mesh.
1 private and internal method
MemberWhat it is
private void PlanePlaneIntersection(out Vector3 linePoint, out Vector3 lineVec, Transform plane1, Transform plane2)Line where two transforms' forward planes meet.