/// <summary> /// Checks the angle restrictions. /// </summary> /// <param name="jointEntity">Joint entity</param> void CheckAngleRestrictions(JointEntity jointEntity) { Vector3 euler = normalizeEuler(jointEntity.Joint.localRotation.eulerAngles); Vector3 newEuler = Vector3.zero; JointActiveAngle jointActiveAngle = jointEntity.activeJointAngle; if (jointEntity.enabled) { if (jointActiveAngle == JointActiveAngle.X) { newEuler.x = Mathf.Clamp(euler.x, jointEntity.angleMin, jointEntity.angleMax); } if (jointActiveAngle == JointActiveAngle.Y) { newEuler.y = Mathf.Clamp(euler.y, jointEntity.angleMin, jointEntity.angleMax); } if (jointActiveAngle == JointActiveAngle.Z) { newEuler.z = Mathf.Clamp(euler.z, jointEntity.angleMin, jointEntity.angleMax); } } jointEntity.Joint.localEulerAngles = newEuler; }
public static float getActiveAngle(IKSolverServo.JointEntity jointEntity) { Vector3 euler = jointEntity.Joint.localEulerAngles; JointActiveAngle jointActiveAngle = jointEntity.activeJointAngle; if (jointActiveAngle == JointActiveAngle.X) { return(euler.x); } else if (jointActiveAngle == JointActiveAngle.Y) { return(euler.y); } return(euler.z); }