Camera2D interia and particularly rotInertia questions

Topics: Developer Forum, User Forum
Jan 16, 2014 at 1:50 PM
Firstly I had the problem of the camera position becoming slower and slower in returning to the bounds set. In fact it would never actually return to the bounds, as the slowing would be faster than the movement in the end no matter what.

However I played with the intertia code and have solved it, although I don't know if this is a very blind and rough fix that may cause problems or not. nonetheless for now it allows the camera to remain elastic but move back to its bounds in a good speed, instead of getting slowed to a crawl a few pixels away.
         Vector2 delta = _targetPosition - _currentPosition;
            float distance = delta.Length();
            if (distance > 0f)
            {
                delta /= distance;                
            }
            float inertia;
            if (distance < 10f)
            {
                    inertia = (float)Math.Pow(distance / 10.0, 1.3); // speed of intertia slowdown. CHANGE WHEN SWITCHING
            }
            else
            {
                inertia = 1f;
            }
However now I wish to achieve something similar for the rotInertia, however my little fix that worked for position (changing the second value of Math.Pow to 1.3 instead of 2.0) cause the screen to simply disappear.

What do I do to the below code to stop the rotation from slowing down to a crawl before resetting it self back to default?

            float rotDelta = _targetRotation - _currentRotation;

            rotInertia = 0f;
            if (Math.Abs(rotDelta) < 5f)
            {
                rotInertia = (float)Math.Pow(rotDelta / 5.0, 2.0);
            }
            else
            {
                rotInertia = 1f;
            }

            if (Math.Abs(rotDelta) > 0f)
            {
                rotDelta /= Math.Abs(rotDelta);
            }
Any help would be massively appreciated.