- Home /
Playing animation frame by frame depending on speed (time)
Hello everyone! I've checked the related posts to my question and the manual, but I wasn't able to find any suitable examples on how to implement my functionality.
I have an object that moves at a player controlled speed (determined via keypressed time). This object has a piece that moves closer or further away, depending on the current speed (imagine a moving rear wing like on a Porsche or on a Veyron). I can control the movement, count/keep speed and trigger the animation start without any problems.
However I feel that the whole thing would look and feel a lot better if the animation's playback rate would depend on the current speed, a bit like this:
-if speed > x, begin playback of n frames (just to start the movement) -while speed is increasing (and up to a limit of y), for each x seconds, play n frames (would raise the wing more smoothly) -if speed is reducing (and up to the lowest boundary of 0) for each x seconds, rewind n frames (would lower the wing smoothly) -if speed falls radically fast or a big collision occurs, may play a preset animation of the wing lowering (since no speed is applied here)
So, I can't seem to find a implementation example of frame-by-frame playback, pause and rewind on the docs and here on the forum...Can anyone give me some pointers about this? Thanks in advance guys!
Best Regards,
-RG
I assume you've looked at this page? http://unity3d.com/support/documentation/ScriptReference/Animation.html
Hi and thanks for the link, Yes I did check it, and although it was useful to kick-off the animation script, I haven't found anything there that points toward frame-by-frame animation control. I thought about using the playback speed (0=pause, if object speed is x then playback speed is y for example), but I'm not sure if that is the best way to approach this issue.