Skip to main content

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.

Constructors​

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

Fields​

12 private and internal fields
MemberWhat it is
private Pickup basePickupPickup that can no longer be docked once the projectile is active.
private Collider[] collidersToDisableColliders switched off when the projectile activates.
private Vector3 directionNormalized push direction in the rigidbody's local space.
private UnityEvent hitWhileFlyingEvent invoked on the server when the active projectile hits something fast enough.
private bool isActiveTrue once Activate has run.
private float minSpeedToExplodeSquaredSquared relative speed a collision must exceed to fire hitWhileFlying.
private AnimationCurve propellingForceOverTimeForce strength over seconds since activation.
private float startTimeReal time when Activate ran.
private Rigidbody targetRigidbodyRigidbody the force is applied to.
private float timeToEnableCollisionSeconds after activation before collisions can fire the hit event.
private float timeToStopKinematicSeconds after activation before the rigidbody is made non-kinematic.
private IUnityUpdateMethod updatePropellingHandle for the registered fixed-update method.

Methods​

MemberWhat 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
MemberWhat 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.