namespace Zinnia.Tracking.Velocity { using UnityEngine; using Zinnia.Extension; /// /// Applies the velocity data from the given to the given . /// public class VelocityApplier : MonoBehaviour { [Tooltip("The source VelocityTracker to receive the velocity data from.")] [SerializeField] private VelocityTracker source; /// /// The source to receive the velocity data from. /// public VelocityTracker Source { get { return source; } set { source = value; } } [Tooltip("The target Rigidbody to apply the source velocity data to.")] [SerializeField] private Rigidbody target; /// /// The target to apply the source velocity data to. /// public Rigidbody Target { get { return target; } set { target = value; } } /// /// Clears . /// public virtual void ClearSource() { if (!this.IsValidState()) { return; } Source = default; } /// /// Clears . /// public virtual void ClearTarget() { if (!this.IsValidState()) { return; } Target = default; } /// /// Applies the velocity data to the . /// public virtual void Apply() { if (!this.IsValidState() || Source == null || Target == null || Target.isKinematic) { return; } Target.velocity = Source.GetVelocity(); Target.angularVelocity = Source.GetAngularVelocity(); } } }