/// <summary> /// Gets the velocity relative to the rigidbodys local coordinates at a point. /// </summary> /// <param name="relativePoint">Point in local coordinates</param> /// <returns>Velocity at a point in local coordinates</returns> public static Vector3 DebugGetRelativePointVelocity(this Rigidbody rigidbody, Vector3 relativePoint) { Vector3 velocity = rigidbody.GetRelativePointVelocity(relativePoint); DebugRigidbody.DrawForce(rigidbody, rigidbody.transform.TransformPoint(relativePoint), rigidbody.transform.TransformDirection(velocity), ForceMode.VelocityChange); return(velocity); }
/// <summary> /// Gets the velocity of the rigidbody at a point in world space /// </summary> /// <param name="worldPoint">Point in word space coordinates</param> /// <returns>Velocity of the rigidbody at point</returns> public static Vector3 DebugGetPointVelocity(this Rigidbody rigidbody, Vector3 worldPoint) { Vector3 velocity = rigidbody.GetPointVelocity(worldPoint); DebugRigidbody.DrawForce(rigidbody, worldPoint, velocity, ForceMode.VelocityChange); return(velocity); }
/// <summary> /// Adds a force to the rigidbody relative to its local coordinate system /// </summary> /// <param name="x">Size of force along local x-axis</param> /// <param name="y">Size of force along local y-axis</param> /// <param name="z">Size of force along local z-axis</param> /// <param name="mode">Type of force to apply</param> public static void DebugAddRelativeForce(this Rigidbody rigidbody, float x, float y, float z, ForceMode mode = ForceMode.Force) { DebugRigidbody.DrawForce(rigidbody, rigidbody.worldCenterOfMass, rigidbody.transform.TransformDirection(new Vector3(x, y, z)), mode); rigidbody.AddRelativeForce(x, y, z, mode); }
/// <summary> /// Adds a force to the rigidbody relative to its local coordinate system /// </summary> /// <param name="force">Force vector in local coordinates</param> /// <param name="mode">Type of force to apply</param> public static void DebugAddRelativeForce(this Rigidbody rigidbody, Vector3 force, ForceMode mode = ForceMode.Force) { DebugRigidbody.DrawForce(rigidbody, rigidbody.worldCenterOfMass, rigidbody.transform.TransformDirection(force), mode); rigidbody.AddRelativeForce(force, mode); }
/// <summary> /// Adds a force to the rigidbody /// </summary> /// <param name="x">Size of force along world x-axis</param> /// <param name="y">Size of force along world y-axis</param> /// <param name="z">Size of force along world z-axis</param> /// <param name="mode">Type of force to apply</param> public static void DebugAddForce(this Rigidbody rigidbody, float x, float y, float z, ForceMode mode = ForceMode.Force) { DebugRigidbody.DrawForce(rigidbody, rigidbody.worldCenterOfMass, new Vector3(x, y, z), mode); rigidbody.AddForce(x, y, z, mode); }
/// <summary> /// Adds a force to the rigidbody /// </summary> /// <param name="force">Force vector in world coordinates</param> /// <param name="mode">Type of force to apply</param> public static void DebugAddForce(this Rigidbody rigidbody, Vector3 force, ForceMode mode = ForceMode.Force) { DebugRigidbody.DrawForce(rigidbody, rigidbody.worldCenterOfMass, force, mode); rigidbody.AddForce(force, mode); }