// Spine (spine/chest/upper chest) rotation quaternion GetSpineRotation() { // Constant bending var r1 = quaternion.RotateX(deg2rad(_spineBend)); // Noise var r2 = Noise.Rotation(_noise, deg2rad(_spineRotationNoise), 1); return(math.mul(r1, r2)); }
// Body (hip) rotation quaternion GetBodyRotation() { // Base offset var r1 = quaternion.RotateY(-math.PI / 2); // Right direction vector based on the foot positions var right = RightFootPosition - LeftFootPosition; right.y = 0; right = math.normalize(right); // Horizontal rotation var r2 = quaternion.LookRotation(right, Up); // Noise var r3 = Noise.Rotation(_noise, deg2rad(_hipRotationNoise), 0); return(math.mul(math.mul(r1, r2), r3)); }