namespace Zinnia.Tracking.Velocity { using UnityEngine; using Zinnia.Extension; /// /// Retrieves the velocity for a . /// public class RigidbodyVelocityTracker : VelocityTracker { [Tooltip("The source to track and estimate velocities for.")] [SerializeField] private Rigidbody source; /// /// The source to track and estimate velocities for. /// public Rigidbody Source { get { return source; } set { source = value; } } /// /// Clears . /// public virtual void ClearSource() { if (!this.IsValidState()) { return; } Source = default; } /// public override bool IsActive() { return base.IsActive() && Source != null && Source.gameObject.activeInHierarchy; } /// protected override Vector3 DoGetAngularVelocity() { return Source != null ? Source.angularVelocity : Vector3.zero; } /// protected override Vector3 DoGetVelocity() { return Source != null ? Source.velocity : Vector3.zero; } } }