- Home /
What's the best way to add per-frame gameplay flags to animations?
I would like to add a number of gameplay-related flags to my character animations, such as specifying the frames in an attack animation during which the character is invulnerable, or the frames in a jump animation during which the player has air control.
I've read about Animation Events, and considered using them to set/unset flags on another component attached to the character, but I'm concerned that there might be a performance issue if every animation fires events both to set and unset several flags.
I've also considered using Animation Curves and creating separate curves for each flag, but the docs specifically warn against using curves for gameplay logic because they may be resampled.
Has anyone used a large number of animation events to implement something similar? Is there a better way to accomplish this? Thanks!,
Answer by Casiell · Aug 14, 2020 at 11:18 PM
If you know how long your animations are you can always start a coroutine at the same time as the animation and set your flags there. Coroutines have very little overhead (certainly less than animation events) and you can easily wait for a specified amount of time/frames and set your flags there