- Home /
Change Properties on First Frame of Animation
So I have the following state machine setup for a bit of UI:
The goal is: when you get a shield, the normal hit bar disappears, the shield bar appears, a shield sprite goes BLAOW and then sits and glows. When you lose the shield, it fades away. Here's the animation setup:
Notice that I've set the enabled
properties of several objects in the first frame, but the particle system isn't enabled until frame seven or so. The problem I'm having is that everything that's supposed to happen in frame one—enabling/disabling objects and setting the scale and colors—doesn't trigger at all. I've tried everything I can think of to convince Unity to play these first frames—I've fiddled with the transition settings, turned looping on/off, etc—and nothing seems to get that first frame to go.
The only thing I can think of is that it's not doing anything because technically nothing is being animated at that point; i.e. there is no previous keyframe to animate from; but that would mean it is impossible to set parameters at the beginning of any animation, which seems wrong, and therefore I must be missing something.
So, what am I doing wrong?
EDIT: Based on my previous suspicion, I tried moving the initial keys to frame two and adding keys with the default values to frame 1, and it does indeed work, which seems to confirm my hypothesis that you can't change properties in frame 1 because they aren't animating from anything, but this still seems like I'm just missing an easier way to do this. Any help would be appreciated because this workaround will get really obnoxious really fast.
Answer by Masterio · Feb 05, 2016 at 02:21 PM
maybe try make script for Animator States:
https://unity3d.com/learn/tutorials/modules/beginner/5-pre-order-beta/state-machine-behaviours
http://docs.unity3d.com/Manual/StateMachineBehaviours.html
It is very useful thing.
Your answer
Follow this Question
Related Questions
Last frame of animation shows up just before the end 0 Answers
Easier way of creating transitions in the animator? 1 Answer
Why does Unity animator makes calling children's SetActive fail? 0 Answers
Transition Between Regular Animations and Ragdoll Physics 3 Answers
Mecanim transition condition can't have both bool and trigger? 0 Answers