- Home /
Animation Window Time Unit
I made an animation to a GameObject as seen below:
I want to do something in a script at the exact time when animation reaches to 0:40. I tried to use yield return new WaitForSeconds(0.4f);
but it didn't work because it caused some delays. My question is:
What does 0:10 in animation window corresponds to in seconds? I don't think it's miliseconds since 1 second = 1000 miliseconds.
How many seconds do I have to wait until animation reaches to 0:40?
Answer by FM-Productions · May 05, 2017 at 01:31 PM
Hi,
simply set an animation event for your animation at the right time. It should call the corresponding function of the script attached to your animated object. Here is the tutorial:
https://docs.unity3d.com/Manual/animeditor-AnimationEvents.html
I haven't tried this yet but I think it will solve my problem. I will let you know when I try it.
Answer by Hellium · Apr 30, 2017 at 05:30 PM
The values in the animation panel must be read as follow :
The first number indicates the seconds, rounded down
The second number indicates the frame number of the current second
Thus, "0:40" must be read as dollow : "40th frame of the first second"
Supposing you have set "60" in the "Sample" input field next to your animation name, in the Animation panel, then your animation is running at 60 frames per second. That's why you have :
"0:00", "0:10", "0:20", "0:30", "0:40", "0:50", "1:00"
Thus, you will have to wait : 40/fps
seconds = 40/60
seconds ~ 0.6667
seconds
I tried it but I still observed a delay. I think it is related to how Unity manages animations and coroutines.
https://docs.unity3d.com/$$anonymous$$anual/animeditor-AnimatingAGameObject.html
Time line
You can click anywhere on the Animation window time line to move the playback head to that frame, and preview or modify that frame in the Animation Clip. The numbers in the time line are shown as seconds and frames, so 1:30 means 1 second and 30 frames.
Your answer
Follow this Question
Related Questions
Loop Animation with delay-variable 1 Answer
Javascript; Wait for animation 1 Answer
How do I make the animation play once then change scene? 0 Answers
Gun script help 1 Answer
Loop animation with a wait in between 3 Answers