I have a rail. On this rail moves a cart.
When the cart moves with default speed on this rail, the movement looks good.
But when I increase the speed of the cart the movement looks not good. First the Code:
private float _dr = 0f;
private float _ar = 0f;
private float _vr = 0f;
private float _targetRotation = 0f;
private float _rotationSpring = 0.1f;
private float _rotationDamping = 0.6f;
_targetRotation = linePath.angle;
if (_targetRotation > _plane.rotation + 180) _targetRotation -= 360;
if (_targetRotation < _plane.rotation - 180) _targetRotation += 360;
_dr = _targetRotation - _plane.rotation;
_ar = _dr * _rotationSpring;
_vr += _ar;
_vr *= _rotationDamping;
_plane.rotation += _vr;
And here is the Image with the problem:
The red rectangle is the speed that is increased. The dotted car is with the default speed.
If you wanna look, I downloaded the original code from here.http://rengelbert.com/blog/linedrawing-the-android-version/
I changed this code a little bit.
There is also another problem. For e.g. After 10 seconds, 20 seconds and so on, the cart
rotates 360 degrees on the rail during movement.
Now, how can I fix the 360 degrees problem and how can I add the variable speed in the ease rotation calculation?
Thanks for any help.