TrainingHittingTool
A class in Root.Township, the global namespace.
A training dummy part that swings on a curve and re-arms its impactor once per cycle. Both sides run the swing; new players get the current progress on connect.
- Listed in Global namespace: T to X
- Inherits or implements
NetworkEntityBehaviour
Constructors
| Member | What it is |
|---|---|
TrainingHittingTool() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
9 private and internal fields
| Member | What it is |
|---|---|
private Collider activeCollider | Collider that can hit; turned off after a hit and back on each new cycle. |
private Quaternion baseRotation | The parent's rotation at Start, which the swing is applied on top of. |
private float currentProgress | How far through the current swing cycle it is, 0 to 1. |
private FixedImpactor fixedImpactor | Impactor charged at the start of each cycle. |
private Vector3 rotationAxis | Axis the swing rotates around. |
private DurationCurve rotationOverTime | Swing angle curve and cycle duration. |
private MethodSync sync | Sync message (SyncA) for currentProgress. |
private Rigidbody targetRigidbody | The rigidbody that is rotated. |
private ImpactTool tool | The impact tool whose collisions are watched. |
Methods
| Member | What it is |
|---|---|
override void Initialize() | Sets up the progress sync message. |
override void OnConnected(Player player) | Sends the current swing progress to the joining player. |
6 private and internal methods
| Member | What it is |
|---|---|
private void Awake() | Hooks the tool's collision event. |
private void Collided(Collision collision, bool isHitting, ImpactTool tool) | Turns off the active collider after the tool hits something, so it hits once per swing. |
private void FixedUpdate() | Advances the swing progress; at the end of each cycle wraps round, re-enables the collider and charges the impactor. |
private void Start() | Records the parent's rotation as the base rotation. |
private void Sync(IPlayer player, Stream stream) | Serializes currentProgress as a 0 to 1 float. |
private void UpdateRotation() | Rotates the rigidbody around rotationAxis by the curve's angle at the current progress. |