Now that the player has gear — individual items in designated slots — I might as well have the player “model” correspond to these parts. Now, this is easier said than done. I need to adjust my part animator logic quite a bit to have them support modular selection of parts.

First, let me copy the junkbot bipedal walker mob animator setup and use it for the player (which is really easy with my modular assets):

Of course, I used just a square before, so I need to lift the gun higher. In fact, so high that I need my editor to show double the size of the current sprite it does in preview:

And that’s much better and probably about the highest a weapon can be “lifted”:

Further, I need to adjust player animation to be faster, especially stepping:

The player is just way faster than the phlegmatic mobs I have.

Finally, adding  a small extra part just so I have something to swap for it:

Of course, I will need all unique sprites, including for each item (urgh).

Now I can start working on splitting the animator into two version — one for the enemy mobs (remains as is) and one for the player (supports multi-part setup):

I want to keep this somewhat simple to begin with, so I will have the player’s multipart setup just reference the “normal” animator:

Internally, it routes all calls and requests to the base setup and basically acts as a mediator. The player definition can reference this multi part setup and it will act just like a normal setup:

Now, I need to start adding some sort of connection between player’s gear and animators. In essence, this is just “show the right sprite”. But also “animate the right way” and “show in the right place and layer”.

The first most straightforward approach would be for each gear item to specify which animator setup they want:

Unfortunately, my setup logic isn’t structured in a way that I can select individual part animations. For now I will just wire the whole animator selection and see where it goes from there.

(Am I over-complicating this? For sure.)

I have to make a special animator selector that the animators can optionally use. Then the player has their gear-based animator selector via the multi part selector. All others just default to the base animator. So when it’s time to look up player’s animator, it return the one that the gear want (hull item here, since I cannot choose parts yet). I can make this less of a mess by having gear not specify any references directly, but rather the designation of the animator:

And then I can list these in the multi-part animator setup instead of just the default one:

And this ends up showing the “right” one in-game:

Of course, this is the whole setup that’s swapped and I’ve hard-coded to use the hull as the item that determines it.

The idea is that I can now add the relevant gear slot to the entries so they match the designation. So a default hull would use the given setup:

Then I can specify this for every slot-designation combination and specify which sprite is supposed to be used from that setup:

At this point, it all gets really confusing with all the designations and indices and lookups. My animator code is not somewhat a mess. I try to make these changes one at a time and then restore everything to working conditions at every step. But I am occasionally stumped regardless. For example, I am adding a preview for what sprite I am even trying to select in my entries:

And looking at this I realize that it is wrong. After all, I have 2 legs. In fact, I need a whole new list where I can specify which slot is supposed to be controlling which sprite (these are in the matching order for sprites):

()

That way, I don’t actually use any sort of indices, but just specify the slot and it an iterate through all the sprites that would be affected/selected:

Putting it all together (which is easier said than done), I can eventually see the player in-game with only the relevant sprites replaced (here, the hull is the big alternate one, but all other sprites are defaults):

Have I totally over-complicated my animation system (again)? Yep. At least for the player — now I need to select the right animator based on the player’s gear. Which sound so simple in principle, but these simplest things are always the biggest problems in larger codebases.

Anyhow, the last remaining thing would be to separate the effects from the animators, like so:

And just have the multi-part selector reference these:

But I realized I cannot actually easily define effects in any of the animators. In fact, just like sprites, my effects are dependent on the gear slot. But effects are per-entry. At best, I can only do for now:

My effects have been broken for a while anyway, so may be that’s something I will be fixing soonish. I might even do effects based on animation presets — walking does steps, hovering does exhaust, etc. We’ll see.

As a side note, all of this is hell of a complex animation selection logic when I could just have a whole animator for a single part. The gather up the relevant animators that way. But that breaks my existing logic for animation, and I rather preserve it. I also cannot preview an “entire” loadout set that way. It’s also not that different, since I would be looking up individual sprite entries anyway, which is the biggest change here. It’s rocky bottom either way.

Well, that about cover making player have parts, at least technically. I need actual sprites for them and sprites for each gear item… yikes! But I think I really need this for customization and replayability.

Related Posts

MicroRogue DevDiary #73 – Player gear-based parts
Tagged on:         

Leave a Reply

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