private void HandHoverUpdate(Hand hand) { // Start moving the control stick. if (user_input.IsTrackpadClick(UserInput.HAND_ID.Right)) { hand_pre_pos = user_input.HandPosition(UserInput.HAND_ID.Right); pre_rotate = GeneralizedEularAngle.Generalized(now_rotate); is_move_valid = true; } }
/* Control plane movement. */ private void LateUpdate() { // Only work in the game. if (GameController.GetGameSTAT() != GameController.GAME_STAT.Game && GameController.GetGameSTAT() != GameController.GAME_STAT.Tutorial) { return; } /* Rotation */ // How we are going to rotate the plane. Vector3 rotate_angle = GeneralizedEularAngle.Generalized(stick_ctrl.NowRotate()); // The plane rotation now. Vector3 plane_rotate = GeneralizedEularAngle.Generalized(transform.rotation); // x axis if (rotate_angle.x > 0 && plane_rotate.x > 80f) { rotate_angle.x = 0; } // y axis float rotate_y = plane_rotate.z / 2f; if (plane_rotate.z * rotate_angle.z < 0) { rotate_y /= 2f; } if (user_input.IsGripPress(UserInput.HAND_ID.Left)) { rotate_y += 2; } if (user_input.IsGripPress(UserInput.HAND_ID.Right)) { rotate_y -= 2; } // Apply rotation. transform.Rotate(new Vector3(rotate_angle.x, rotate_angle.y - rotate_y, rotate_angle.z) * Time.deltaTime); // Move forward. transform.Translate(transform.forward * speed * Time.deltaTime, Space.World); // Falling. if (speed < 30f) { transform.Translate(Vector3.down * (30f - speed) * 2f * Time.deltaTime, Space.World); if (plane_rotate.x < 80f) { transform.Rotate(new Vector3((30f - speed), 0, 0) * Time.deltaTime); } } }