for my 3D og doomlike game, I want it so that when my enemy is on a certain frame of his attack animation and the player is within a certain distance, then something happens(for example the player takes damage). But I don’t know how to check what my enemy’s current sprite is. I’m using c# by the way.
You don’t want to handle it by checking which sprite an animation is choosing, for a wide number of reasons:
-
frame rate could stutter, and the animation system will skip a sprite entirely. If that’s the sprite you’re waiting for, you won’t trigger.
-
you could in the future decide “I shall change how this enemy looks” and forget that some other component in the LOGIC sife of things is watching for that sprite, which like anything visual, is not LOGIC, but rather lives in the PRESENTATION space, conceptually.
Instead, use something like Unity’s Animation Events. This is pretty much what they are for:
1 Like
o, ok, thanks man!