- Home /
Does an animation continuously set it's frame values?
Example: I have a bool set to true on frame 10 and then on frame 15 it's set to false. In between frame 10 and 11, if I have a script set the bool to false, will it automatically set it to true on frame 11?
Answer by Vollmondum · Apr 06, 2019 at 04:04 AM
Yes, each frame is copied from previous on each parameter. Say, if you set a bool to true on frame 5, and then script it to false at frame 100 outside animation, it becomes true again on 101. Great way to bypass it is to create 2 bools for the same parameter. Animation sets a bool to false, and the script sets another bool to true if current one becomes false. And doesn't matter if the first one becomes true again.
What if I set it false after frame 14, so frame 15 already sets it to false. Will it still be set to true after my script has set it to false?
In my experience I use three bools, say damage, damaging, damaged.
Generally, yes it's possible. Note that animations are not based on frames but on keyframes. So you can not really rely on a certain state since the animations are "time based". So Your animations actually have curves. Unity samples those curves at the current time which can be in between two frames. If you have an "impulse curve" (suddenly going from 0 to 1) if the time is before that keyframe it will be set to false, if it's after it will be true. Animation curves are there to represent the state during the whole animation. If you animate a value you shouldn't mess with it from outside.
If you just want to fire an event at a certain time you can use animation events. Animation events do not represent the state over time. They just execute code once the animation sweeps by the time where you set the event. To me it sounds like you want to use animation events ins$$anonymous$$d of curves.
Your answer
Follow this Question
Related Questions
Blend Tree Transition Conditions. 0 Answers
Animations in booleans loop? 1 Answer
Stop Animation State in Animator from Speeding Up after Playing it a Second Time? 0 Answers
Make condition for opening a door (can only be opened when a lever has been activated before) 1 Answer
How do I stop my animation from looping while I hold down a key? 1 Answer