Show gear in 2D spritesheet animations

Hi everyone,
I’ve got the problem that I got a ‘naked’ character and since I want to create a roguelike game I want to be able to collect gear. Also I want to display this on the character. We are talking about a Head - Torso - Legs.

For all the animations of the character I have the animations of the gear as well. (same number of sprites for all the frames etc.)

But how can I create this effect without making all animations for all possible combinations in all directions? Or is this something that can not be done? I’ve tried to create a animation manager but then the frames don’t line up…

Please help!

Romek.

8505164--1132889--upload_2022-10-11_14-4-14.png

Everything can be done, it’s just a matter of effort.

These things (character customization, inventories, shop systems) are fairly tricky hairy beasts, definitely deep in advanced coding territory. They contain elements of:

  • a database of items that you may possibly possess / equip
  • a database of the items that you actually possess / equip currently
  • perhaps another database of your “storage” area at home base?
  • persistence of this information to storage between game runs
  • presentation of the inventory to the user (may have to scale and grow, overlay parts, clothing, etc)
  • interaction with items in the inventory or on the character or in the home base storage area
  • interaction with the world to get items in and out
  • dependence on asset definition (images, etc.) for presentation

Just the design choices of an inventory system can have a lot of complicating confounding issues, such as:

  • can you have multiple items? Is there a limit?
  • if there is an item limit, what is it? Total count? Weight? Size? Something else?
  • are those items shown individually or do they stack?
  • are coins / gems stacked but other stuff isn’t stacked?
  • do items have detailed data shown (durability, rarity, damage, etc.)?
  • can users combine items to make new items? How? Limits? Results? Messages of success/failure?
  • can users substantially modify items with other things like spells, gems, sockets, etc.?
  • does a worn-out item (shovel) become something else (like a stick) when the item wears out fully?
  • etc.

Your best bet is probably to write down exactly what you want feature-wise. It may be useful to get very familiar with an existing game so you have an actual example of each feature in action.

Once you have decided a baseline design, fully work through two or three different inventory tutorials on Youtube, perhaps even for the game example you have chosen above.

Or… do like I like to do: just jump in and make it up as you go. It is SOFT-ware after all… evolve it as you go! :slight_smile:

Breaking down a large problem such as inventory:

https://discussions.unity.com/t/826141/4

This is completely besides the point and not what was asked at all though. He wants to know how to work this into the animation system, not how to implement the items themselves or how to manage inventory systems. Not sure where you got this from.

Unfortunately it is true that this is an extremely finnicky issue. There are a few solutions, but all of them are very specific to the way your game and assets are set up, so it’s hard to just give you a generic way to display the items on your character. I’ll give you a few ideas, but they all kind of suck to be honest.

  • Have child objects that are at the position of your equipment on your player character. Then animate those child objects from your main player object. To swap out equipment just swap the sprites. Might lead to a style of animation you don’t want though and requires extra effort if you want differently animated weapons.

  • As you mentioned, make these animations for every single possible combination of items. Yes, this is a valid way of doing it and it is how a lot of (older) games did this. It’s mind-numbingly boring and tedious work, but since you are using pixel art, there’s no real easy way to just swap out parts of the sprite and they basically have to be completely replaced/redrawn every time. Maybe take a look at Unity’s Sprite Swap package. It allows you to swap out sprites in animations, but you’ll need to look up some tutorials. I found it to be rather unintuitive when I last used it.

  • Write your own custom animation system without the Animator. If you’re just swapping around sprites, this should be fairly easy and gives you complete control over what you’re trying to do. I mean, to create this flipbook-style animation you just have to go through the sprites one by one. And then you can place your equipment on top and swap that around as well. Might actually be the best way.

Here are a few videos from a really good tutorial series that has what you are talking about

As mentioned above, the system the videos use may not be 1x1 compatible to how your framework is set up. But i do recommend the entire series since the coding and principles are very solid. The channel is Inscope Studios

make one animation with black frames. ( For example if your walk animation has 3 frames make an animation with 3 black frames)

create a separate child game object that has no sprite renderer with an animator that plays your walk animation

use code to detect the current frame of your walk animation ( 1, 2 or 3)

based on this, change sprite on your sprite renderer to your walk animation frame 1, 2 or 3

this way you only need 1 animation for all combinations, and only 1 animator