In this prolonged post I will implement effects that semi-automatically spawn based on the animation, so that I don’t have to specify fiddly values for every mob and such.

Time traveler note: Half-way I realized I am doing things wrong and had to make many adjustments. Such is life.

First things first, I am moving mob animation effects away from the main animation asset:

That way I can specify animation without all the excess effect editor stuff. And my assets are cleanly linked:

This new asset only has the effect stuff, although it is for now unwired:

In order to identify which effect I want, I can use the animation type of the animated part entries. So if the mob is walking and they are doing a “step right”, I can assign an appropriate effect:

First attempt were dubious (before I restricted states properly):

I am using my new effect location editor-time preview to see which states will spawn the effects where:

There is a problem however in that my effect timing doesn’t match my mob animation timing. For example, the player moves twice as quickly:

And this means that the effects are half as fast and basically broken (if you pay attention):

This mean I need an effect entry for each combination of animation type and its modifier:

But I also want to reuse values, so the effects don’t require me to re-enter the same values for the same effect, just different modifier:

I also want to make sure to remind myself if I forget to make it for some modifier:

And to make sure that all my effects actually have a parent effect they can get values from:

Now I can actually add the appropriate “modified” effect fields, such as the speed multiplier:

And this makes the player spawn effect at the right speed:

And this looks really promising… until I tried adjusting these for different mobs. For example, my boss mob reuses the same step animations, but I only have the two specified and I have no quick way of adjusting these or the other two:

In fact, I need a better way to edit these now that I have moved them out of the asset. I can’t click between assets — that’s just ridiculously slow and tedious. Instead, I made a preview, which shows the editable values for relevant animations:

That way I can tweak values live and see the preview:

Except… the boss has different leg/part offsets. They don’t actually match what the regular mobs have. Whoops! So now I have to also have to account for individual part offsets for that animation, which seriously overcomplicated matters. I also have to account for movement direction and facing direction. And suddenly I’m just duplicating everything again. Oh, and the “thighs” move like steps but shouldn’t be making effects…

And this is where I have to scrap a lot of the additions and approach the whole thing differently. At this point I’ve already spent a whole lot of time and I’m spending more time trying to get these working the way I want.

So my new approach is going to be designer-friendly and reusable from animations. An animation will simply specify the times at which it wants to spawn a certain effect. Basically, this would look like this under each animation:

An animation wants a “step” effect to happen 50% along the way. This would match when the foot hits the ground.

In fact, I am going to trim all the values from my effect setups just down to this effect type and the straight-up definition (no bundles, so I can manually time and spawn these one-time effects):

I have to redo a lot of the animator’s logic, but it basically comes down to keeping track of each trigger for each part for each animator. (It’s not too bad when it’s all organized.) If a part can spawn effects, like a mob’s foot, then it keep a timer for each animation trigger and spawn the effect when it hits its threshold:

Due to frame timing, these have to be carefully checked to hit as soon as needed. I won’t bother adding my frame-smoothing here yet as with other effects.

I am also making sure I can preview everything in the editor. One feature I needed to add was a quick speed scale selection, so I can preview the animation slowed down:

I need this because I am going to show when and where effects spawn, but they are so quick that it’s not easy to accurately adjust them.

I also need to adjust my animator entries to have a checkbox that indicates if they actually spawn any effects:

I need this because a boss has a “foot” and “thigh” part and both use the walk/step animation. But I don’t want thighs to create any effects. So I need to toggle off effects for that part so that the animator doesn’t track any animation triggers for it.

So now I am ready to spawn the effects at precise times. And I can look up the part’s position at that exact frame, so I can spawn the effect exactly where the part is. There’s a lot more stuff and code I had to do, but the end result is that I can now have an aligned effect position determined exactly when the part is at that point (little screw is where the sprite’s pivot is):

(50% speed)

I also added the fading effect stuff, so that I can actually preview when it happens. I had quite a lot of trouble debugging when timers go wrong. This way, it’s very visual and clear.

This account for part offsets, speeds, direction, etc. So it works for every mob:

One last thing is that I want to offset the effect spawning a little bit. I can actually add this to the part defaults/commons for the animator. I am basically specifying where each sprite’s effect-spawning location is. This I have to do on a per-mob basis, simply because mobs have different sprites and (unless I make my sprites modularly selected) I can’t know what the exact offsets are. So I’m adding that field:

And now my effects spawn exactly where I want them:

Phew. I am taking a break from animations.

I am making a mess of all these assets. It’s still better than individually editing each one. But if I ever do animation again, I will have all of them in one central window always previewing, individually editable and sharing all the common properties. I can still do this now, but I worry about the time sink for marginal benefit. Regardless, having the animation logic encapsulated and thus previewable in editor was a very good choice. I will consider reusing this animation system for future project, but I think I will need to adjust quite a few thinks to make it easier to work with.

Related Posts

MicroRogue DevDiary #76 – Animation-based effects
Tagged on:             

Leave a Reply

Your email address will not be published. Required fields are marked *