So, I have a spritesheet having different animations of the player
My code basically updates the sprite index for animation and resets back to zero if the index becomes greater than max frames,
This logic works fine for aniamtions having same amount of frame count(like idle and walk)
but gives index doesn't exist for shorter animations(like attack which has just 4 frames)
This is the player code: