system
1
I have an animation called punch which is 12 frames long. The punch animation contains a startup period [frames 1 to 5] an active period [frames 6 to 7] and a recovery period [frames 8 - 12].
On the active frames [6 to 7] I want to place a collision box where the punch takes place.
But I can not figure out how to tell when the punch animation is on frames 6 and 7.
There doesn't seem to be a way to access the actual frame the animation on, but you can access the time the animation has been playing. Something like this should work:
AnimationState PunchAnim = animation["Punch"];
if (PunchAnim.normalizedTime > (6.0f / 12.0f)
&& PunchAnim.normalizedTime < (8.0f / 12.0f))
{
// collider active
}