- Home /
Need help with animation rewind
i want to make a character walk i have the animation set up and the character i have not started scripting it yet but i want to know how i can rewind to a certain frame i know how to use animation.Rewind(); but how do i rewind to a specific frame for example when the character walks the walk animation loops until i let go then i want it to rewind to the frame where he is stud still instead of just snaping there straight away. thanks
Answer by lil_billy · Nov 17, 2012 at 08:54 PM
So you are about to learn that unity's animation system is a pain in the ass
The problem is animation does not actually play when you tell it (as far as I can understand its arbitrary when it plays)
because of this we are rather limited in what we can do with animations
in other words what you are asking is for is impossible you cannot access the frames of an animation (when it comes to playing them in code)
However I get the feeling that your actual problem is different than what you are saying
When you import a model it brings all of its animations in as one large timeline When you import a model you can click on it in the project heirarchy
there you can access that timeline and you can divide it up based on the FRAMES into new individual clips. Those clips you can then play in your code whenever you want so you can divide up your walk animations from say your punch animation
and when you play it will only play that unique clip.
I tried to find the page that explained this but its missing so heres a video http://www.youtube.com/watch?v=p25SFf6Kf0g
i have divided the animations but what i want to do is when im walking the animation plays but then when i let go of forward ins$$anonymous$$d of the legs snaping straight back to play the idle animtion i wanted it to rewind to the last time the legs were both straight or almost straight then play the idle animation so it looks more smooth
then either you need to divide your clips better or animate the model better
actually I think im getting confused with what you are asking, please describe your animations better.
This probably could be resolved with wrapmodes
Sorry for the late reply , what I want my character to do is the same thing people do in real life when you walk your les move but when you stop your legs bring them selfs together so You can stand ,what I'm trying to achieve is this ins$$anonymous$$d of me character going from his legs spread out him standing I want him to bring his legs back to part of the walk animation where his legs are together
then you have your walk animation and what is known as an idle animation and then you CrossFade between them
Technically, frame X of an animation can be reached by sampling the animation at time = (fps * x)/clip.length.