void DoGetDeviceAcceleration()
        {
            /*			var dir = Vector3.zero;
             *
             *          switch (mappingOptions)
             *          {
             *          case MappingOptions.Flat:
             *
             *              dir.x = Input.acceleration.x;
             *              dir.y = Input.acceleration.z;
             *              dir.z = Input.acceleration.y;
             *              break;
             *
             *
             *          case MappingOptions.Vertical:
             *              dir.x = Input.acceleration.x;
             *              dir.y = Input.acceleration.y;
             *              dir.z = Input.acceleration.x;
             *              break;
             *          }
             */

            var dir = ActionHelpers.GetDeviceAcceleration();

            if (!multiplier.IsNone)
            {
                dir *= multiplier.Value;
            }

            storeVector.Value = dir;
            storeX.Value      = dir.x;
            storeY.Value      = dir.y;
            storeZ.Value      = dir.z;
        }
        public override void OnUpdate()
        {
            var acceleration = ActionHelpers.GetDeviceAcceleration();

            if (acceleration.sqrMagnitude > (shakeThreshold.Value * shakeThreshold.Value))
            {
                Fsm.Event(sendEvent);
            }
        }
示例#3
0
        void DoGetDeviceRoll()
        {
            var   acceleration = ActionHelpers.GetDeviceAcceleration();
            float x            = acceleration.x;
            float y            = acceleration.y;
            float zAngle       = 0;

            switch (baseOrientation)
            {
            case BaseOrientation.Portrait:
                zAngle = -Mathf.Atan2(x, -y);
                break;

            case BaseOrientation.LandscapeLeft:
                zAngle = Mathf.Atan2(y, -x);
                break;

            case BaseOrientation.LandscapeRight:
                zAngle = -Mathf.Atan2(y, x);
                break;
            }

            if (!limitAngle.IsNone)
            {
                zAngle = Mathf.Clamp(Mathf.Rad2Deg * zAngle, -limitAngle.Value, limitAngle.Value);
            }

            if (smoothing.Value > 0)
            {
                zAngle = Mathf.LerpAngle(lastZAngle, zAngle, smoothing.Value * Time.deltaTime);
            }

            lastZAngle = zAngle;

            storeAngle.Value = zAngle;
        }