void Update() { double t = Math.Sin(Time.time * Math.PI); // [-1, 1] double s = (t + 1) / 2; // [0, 1] a = int.Parse(UDP.text); if (a == 0) { leftUpperArm.offset((float)(80 * 1), 0, 0, 1); leftLowerArm.offset((float)(150 * s), 1, 0, 0); rightUpperArm.offset((float)(90 * -1), 0, 0, 1); rightUpperLeg.offset((float)(-90 * 0), 1, 0, 0); rightLowerLeg.offset((float)(90 * 0), 1, 0, 0); humanoid.transform.rotation = Quaternion.AngleAxis(bodyRotation.z, new Vector3(0, 0, 1)) * Quaternion.AngleAxis(bodyRotation.x, new Vector3(1, 0, 0)) * Quaternion.AngleAxis(bodyRotation.y, new Vector3(0, 1, 0)); } if (a == 1) { leftUpperArm.offset((float)(90 * 1), 1, 0, 0); leftLowerArm.offset((float)(180 * t), 0, 1, 0); rightUpperArm.offset((float)(90 * -1), 0, 0, 1); rightUpperLeg.offset((float)(-90 * 0), 1, 0, 0); rightLowerLeg.offset((float)(90 * 0), 1, 0, 0); humanoid.transform.rotation = Quaternion.AngleAxis(bodyRotation.z, new Vector3(0, 0, 1)) * Quaternion.AngleAxis(bodyRotation.x, new Vector3(1, 0, 0)) * Quaternion.AngleAxis(bodyRotation.y, new Vector3(0, 1, 0)); } if (a == 2) { leftUpperArm.offset((float)(80 * 1), 1, 0, 0); leftLowerArm.offset((float)(90 * 0), 1, 0, 0); rightUpperArm.offset((float)(90 * -1), 0, 0, 1); rightUpperLeg.offset((float)(-90 * 0), 1, 0, 0); rightLowerLeg.offset((float)(90 * 0), 1, 0, 0); humanoid.transform.rotation = Quaternion.AngleAxis(bodyRotation.z, new Vector3(0, 0, 1)) * Quaternion.AngleAxis(bodyRotation.x, new Vector3(1, 0, 0)) * Quaternion.AngleAxis(bodyRotation.y, new Vector3(0, 1, 0)); } //一秒間(1000ミリ秒)停止する //System.Threading.Thread.Sleep(1000); if (Input.GetKey(KeyCode.Escape)) { Application.Quit(); } }
void Update() { double t = Math.Sin(Time.time * Math.PI); // [-1, 1] double s = (t + 1) / 2; // [0, 1] leftUpperArm.offset((float)(80 * t), 1, 0, 0); leftLowerArm.offset((float)(90 * s), 1, 0, 0); rightUpperArm.offset((float)(90 * t), 0, 0, 1); rightUpperLeg.offset((float)(-90 * s), 1, 0, 0); rightLowerLeg.offset((float)(90 * s), 1, 0, 0); humanoid.transform.rotation = Quaternion.AngleAxis(bodyRotation.z, new Vector3(0, 0, 1)) * Quaternion.AngleAxis(bodyRotation.x, new Vector3(1, 0, 0)) * Quaternion.AngleAxis(bodyRotation.y, new Vector3(0, 1, 0)); }