I am trying to create a spinning wheel which slows down after a specific time. I managed to simulate the slowdown of the wheel but I need also to put a needle which go up and down with an angle of 45°.
Here my wheel with the needle :
My wheel turn in clockwise and the needle (object in red in the above scheme) rotate in counter clockwise.
Once done the needle back to his original position slower than the previous movement.
The code i wrote :
// Once 3 seconds are passed, the speed rotation start to decrease If RealMillisecs() -_fRotateTime > 3000 Then If _fSpeedRotation > 0 Then _fSpeedRotation = _fSpeedRotation - 0.001 Else _fSpeedRotation = 0 EndIf EndIf _fWheelRotation -= _fSpeedRotation * dt.frametime // If the needle is not going back to its orginal position then is going up If not _bAnimBackNeedle Then _fNeedleRotation = _fWheelRotation Mod 45 * -1 /* If its previous rotation greater than actual position it's mean that the needle has reach its max angle (45)*/ If _fNeedleRotation < _fPreviousNeedleRotation Then _bAnimBackNeedle = True // The going back animation to true EndIf _fPreviousNeedleRotation = _fNeedleRotation EndIf // If the going back animation is set to true or the wheel has stopped to turn // get the needle back to its position at constant speed If _bAnimBackNeedle Or _fSpeedRotation = 0 Then _fNeedleRotation -= 0.5 * dt.frametime If _fNeedleRotation <= 0 Then _bAnimBackNeedle = False EndIf EndIf
My code doesn't make what i hope.
The needle doesn't come back to its original position when the wheel is stopped.
How can I managed the code to have the wheel and the needle with a good behaviour?