Wow AFRLme! That sounds very nice!
My solution calculates the fastest turn with simple if else statements based on whether the target direction lies between the start direction and the start direction +/- 180° (+180° if the start direction is smaller than 180° and -180° if the start direction is bigger than 180°):
if startDirection == 0 then startDirection = 360 end
if endDirection == 0 then endDirection = 360 end
if startDirection > 180 then
if endDirection > startDirection - 180 and endDirection < startDirection then
return true
else
return false
end
else
if endDirection > startDirection + 180 or endDirection < startDirection then
return true
else
return false
end
end
if this code returns true, it should turn the character clockwise. With a false return, it should turn the character anti-clockwise ergo play the turn animation backwards.
With the script-part from SimonS I get back the correct frame for the start & target direction and this is now always the shortest turn. It also gives a little randomness to 180° turns since it calculates the turns based on real directions.
I forgot to mention that there is a problem with that "one animation for the whole turn" solution. It seams that Visionaire don't play the animation from the last frame to the first one. If it reaches the real last frame it stops and don't continue with the first one. (Like first frame of the turn is 4 and last frame is 1 playing forward). For this case I added another 360° turn to the animation and set the start and/or end frame to what it is + the numbers of frames in a whole 360° turn.
Tested it with the demo above (45° steps) and also with 90° steps but it should work with any amount of steps. If we could manage it to set different animations for each turn, it would simplify the animation handling part in the script and it then could be a working solution.
I'll see what I can do but for now I need some weekend. ;-)
Thanks again for all the input!