I have searched the deepest parts of the web and I cannot find ANYTHING that will just simply reset the animation to frame0. WHY WHY WHY WHY WHY is there not a god damn simple function to do this. NOTHING I have tried works. Ive tried fucking rebind, Animator.Play(“name”, 0, 0.0f); and every other code combination in between. WTF unity. when I create an scale animation on a simple image plane It loops. So i turn loop off which results in the animation being stuck on the last frame permanently. When I mouse over an object the image plane is supposed to expand but without being able to reset the frame back to 0 every time it mouses over its already at the last frame of animation from the previous mouse enter. I don’t want to me convoluted code, just a simple reset the fucking animation to frame 0 which seems to be a highly overlooked on unitys part. Ive had this issue so many times and unity keeps fucking changing how to reset the animation. They need to stop people from doing stupid tricks to reset the animation to frame 0.
Even with a saved scene unity looses all my animator information and reverts shit back to 5 scenes ago. I loose hours of work. Unity has crashed 27 times today with me trying to fucking fix this and some stupid fucking bug is causing me to loose all kinds of options, assigned files, changes in unity, the animator, game objects. Im tearing my fucking hair out.
2 Likes
What is this animation you’re trying to play?
Could you use legacy Animation insted of Mecanim? Cause it’s really easy to set the frame for the animation in legacy.
1 Like
I could do it a different way. The point is this is a major issue. Also the fucking animator that I am creating these animations in keeps losing its fucking animations. I’ll save the scene and it will loose the fucking animations i have recorded. it’s like half these shit in unity gets saved and when it crashes half the other shit reverts back to 10 scene saves ago. I have been working on this game for 2 years now and it’s a major fucking problem now. shit hre and there is not being saved when it crashes lately. I save every 10 minutes and I’m losing days worth of work. when I select the animation in the animation drop down editor it has no keyframes recorded. Yet when i play my game it expands half the image plane. where the fuck is it getting the keyframes from? its so jacked up right now. I just updated to the latest version of unity and it still sucks now.
To reset an animation to frame 0 and pause:
Animation animation;
animation.SampleAnimation(gameObjectToAnimate,0);
animation.Stop();
To reset mecanim and pause it:
Animator animator;
animator.CrossFade("StateToSetTo",0);
//I think you'll have to yield and set this next frame, unsure
animator.speed = 0;
Its important to remember that both zeros used here are 0f normalizedTime, not 0 frames
1 Like
Thank you, Updating to unity newest version last night. Today it is working, launched in new version of unity. Last night must have launched prev version. The following code below is now working. Changed nothing, but an update must have fixed an issue with that code. For anyone’s future reference. in unity 5.6.2f1 the below code works for resetting to frame 0.
Animator.Play(“ClipName”, 0, 0.0f);
2 Likes