Ejemplo n.º 1
0
        // Update is called once per frame
        void Update()
        {
            float targetAngle = (float)MathHelper.GetDegreesInRange(-(GetHeading() + Offset));

            if (UseDampening)
            {
                float   currAngle;
                Vector3 currAxis;

                gameObject.transform.localRotation.ToAngleAxis(out currAngle, out currAxis);

                targetAngle = MathHelper.ApproachAngle(currAngle, targetAngle, 0.1f, Time.deltaTime);
            }

            this.gameObject.transform.localRotation = Quaternion.AngleAxis(targetAngle, Axis);
        }
Ejemplo n.º 2
0
        // Update is called once per frame
        void Update()
        {
            var heading = ForegroundPositionService.Instance.Compass.TrueHeading;

            m_lastHeading = MathHelper.ApproachAngle(m_lastHeading, heading, Dampening, Time.deltaTime);

            var dh = m_lastHeading - heading;

            if (dh < -180)
            {
                dh += 360;
            }
            else if (dh > 180)
            {
                dh -= 360;
            }

            var deflection = Mathf.Clamp((float)(dh), -MaxPeek, MaxPeek);

            this.gameObject.transform.localRotation = Quaternion.AngleAxis(deflection, Axis);
        }