void FixedUpdate()
    {
        Vector3 yawPitchRoll = Vector3.zero;
        Vector3 xzVelocity   = Vector3.zero;

        // Apply orientation to the object
        yawPitchRoll = ReadYawPitchRollFromArduino();
        if (yawPitchRoll.Equals(INVALID_VALUE))
        {
            return;
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            Reset(yawPitchRoll);
            yawPitchRoll = Vector3.zero;
        }
        else
        if (_isEnabled)
        {
            ApplyLeftRightForce(yawPitchRoll.z);
        }
        else
        {
            _servoController.EventSetServoPosition(512);
        }

        /*else
         *      _controlOrientation.transform.localEulerAngles = yawPitchRoll;
         *
         * // Rotate container to front-face flight direction in X-Z plane as player doesn't move in it.
         * if (_steerWithYaw) {
         *      _cubeRotation.y += yawPitchRoll.y * YAW_STEER_SCALER;
         *      _controlPosition.transform.localEulerAngles = _cubeRotation;
         * }
         *
         * // Always fly frontface
         * GetRigidBody().velocity = _controlOrientation.transform.forward * GetRigidBody().velocity.magnitude;
         *
         * // Apply forces
         * if (_jetpack)
         *      ApplyJetpackForce(yawPitchRoll);
         * if (_aerodynamics)
         *      ApplyAerodynamicForce(yawPitchRoll);
         */
    }
Esempio n. 2
0
 // Use this for initialization
 void Start()
 {
     servoClient = new ServoControllerClient();
     servoClient.EventSetServoPosition(position);
 }