Example #1
0
        void UpdateVirtualAxes(Vector3 value)
        {
            Vector3 delta = m_StartPos - value;

            delta.y = -delta.y;
            delta  /= MovementRange;
            if (m_UseX)
            {
                m_HorizontalVirtualAxis.Update(-delta.x);
            }

            if (m_UseY)
            {
                m_VerticalVirtualAxis.Update(delta.y);
            }
        }
Example #2
0
        private void Update()
        {
            float angle = 0;

            if (Input.acceleration != Vector3.zero)
            {
                switch (tiltAroundAxis)
                {
                case AxisOptions.ForwardAxis:
                    angle = Mathf.Atan2(Input.acceleration.x, -Input.acceleration.y) * Mathf.Rad2Deg +
                            centreAngleOffset;
                    break;

                case AxisOptions.SidewaysAxis:
                    angle = Mathf.Atan2(Input.acceleration.z, -Input.acceleration.y) * Mathf.Rad2Deg +
                            centreAngleOffset;
                    break;
                }
            }

            float axisValue = Mathf.InverseLerp(-fullTiltAngle, fullTiltAngle, angle) * 2 - 1;

            switch (mapping.type)
            {
            case AxisMapping.MappingType.NamedAxis:
                m_SteerAxis.Update(axisValue);
                break;

            case AxisMapping.MappingType.MousePositionX:
                CrossPlatformInputManager.SetVirtualMousePositionX(axisValue * Screen.width);
                break;

            case AxisMapping.MappingType.MousePositionY:
                CrossPlatformInputManager.SetVirtualMousePositionY(axisValue * Screen.width);
                break;

            case AxisMapping.MappingType.MousePositionZ:
                CrossPlatformInputManager.SetVirtualMousePositionZ(axisValue * Screen.width);
                break;
            }
        }