PropelledProjectile
A class in Root.Township, the global namespace.
Pushes a rigidbody along a set direction with a force curve over time once activated, like a rocket, and fires an event if it hits something hard enough. Server raises the hit event.
- Listed in Global namespace: P
- Inherits or implements
MonoBehaviour
Constructors
| Member | What it is |
|---|---|
PropelledProjectile() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
12 private and internal fields
| Member | What it is |
|---|---|
private Pickup basePickup | Pickup that can no longer be docked once the projectile is active. |
private Collider[] collidersToDisable | Colliders switched off when the projectile activates. |
private Vector3 direction | Normalized push direction in the rigidbody's local space. |
private UnityEvent hitWhileFlying | Event invoked on the server when the active projectile hits something fast enough. |
private bool isActive | True once Activate has run. |
private float minSpeedToExplodeSquared | Squared relative speed a collision must exceed to fire hitWhileFlying. |
private AnimationCurve propellingForceOverTime | Force strength over seconds since activation. |
private float startTime | Real time when Activate ran. |
private Rigidbody targetRigidbody | Rigidbody the force is applied to. |
private float timeToEnableCollision | Seconds after activation before collisions can fire the hit event. |
private float timeToStopKinematic | Seconds after activation before the rigidbody is made non-kinematic. |
private IUnityUpdateMethod updatePropelling | Handle for the registered fixed-update method. |
Methods
| Member | What it is |
|---|---|
void Activate() | Starts propelling: disables the listed colliders, blocks docking on the base pickup and registers the fixed-update force loop. Only runs once. |
5 private and internal methods
| Member | What it is |
|---|---|
private void OnCollisionEnter(Collision collision) | Server: fires hitWhileFlying if active, past timeToEnableCollision and the impact speed beats the minimum. |
private void OnDestroy() | Deregisters the propelling update. |
private void OnDrawGizmosSelected() | Editor: draws the push direction as a red line from the rigidbody. |
private void PreventDocking(Interactor interactor, PickupDock dock, ref bool result) | Dock filter added to the base pickup on activation; always refuses docking. |
private void UpdatePropelling() | Fixed-update step: turns off kinematic after timeToStopKinematic and adds the curve's force along direction in local space. |