private void OnDrawGizmosSelected() { if (!m_doDrawGizmos) { return; } Vector3 rperp = Vector3.up; Vector3 forward = rotationAxis; if (jointType == FeatherstoneJointType.Planar || jointType == FeatherstoneJointType.Prismatic || jointType == FeatherstoneJointType.Revolute) { //uses axis of rotation if (rotationAxis != Vector3.zero) { BUtility.GetPerpendicularVector(forward, out rperp); Vector3 axisOfRotation; if (axesAreFrozen) { axisOfRotation = transform.parent.TransformDirection(rotationAxisInParentFrame); rperp = transform.parent.TransformDirection(jointToThisCOMInParentFrame); } else { axisOfRotation = transform.TransformDirection(rotationAxis); rperp = transform.TransformDirection(-localPivotPosition); if (rperp.magnitude < 10E-7f) { rperp = transform.parent.position - transform.TransformPoint(localPivotPosition); } rperp = Vector3.ProjectOnPlane(rperp, axisOfRotation); } rperp.Normalize(); } } else { rotationAxis = transform.forward; rperp = transform.up; } BUtility.DebugDrawTransform(transform, localPivotPosition, rotationAxis, rperp, gizmoScale); }