Search Unity

Question Change Multiple Character Sprites

Discussion in '2D' started by Almost73, Jun 3, 2023.

  1. Almost73

    Almost73

    Joined:
    Apr 28, 2023
    Posts:
    8
    Hello,
    In my project I want to make multiple skins for the main character.
    I made one movement tree and animations with the default skin. However now I am curious, how do I implement multiple character skins?
    The only thing that comes to mind is to make multiple character movement trees for for each separate skin. But I have a feeling that there is a more efficient way to do this, because Im imagining things can get convoluted the more skins you add.
    As some extra info, the game is 2D top down, animation is sprite based and character can change skins only in a "Dressing Room".
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,736
    Hurry and get started, these things have a LOT of moving parts and can easily take the rest of your life if you don't properly define what you want, realize what you can do, and get implementing NOW.

    Here's what you are looking at:

    These things (inventory, shop systems, character customization, dialog tree systems, crafting, etc) are fairly tricky hairy beasts, definitely deep in advanced coding territory.

    Inventory code never lives "all by itself." All inventory code is EXTREMELY tightly bound to prefabs and/or assets used to display and present and control the inventory. Problems and solutions must consider both code and assets as well as scene / prefab setup and connectivity.

    Inventories / shop systems / character selectors all 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 such a 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.

    Breaking down a large problem such as inventory:

    https://forum.unity.com/threads/weapon-inventory-and-how-to-script-weapons.1046236/#post-6769558

    If you want to see most of the steps involved, make a "micro inventory" in your game, something whereby the player can have (or not have) a single item, and display that item in the UI, and let the user select that item and do things with it (take, drop, use, wear, eat, sell, buy, etc.).

    Everything you learn doing that "micro inventory" of one item will apply when you have any larger more complex inventory, and it will give you a feel for what you are dealing with.

    Breaking down large problems in general:

    https://forum.unity.com/threads/opt...n-an-asteroid-belt-game.1395319/#post-8781697

    But whatever you do, get started NOW... these things do not build themselves out of forum answers.

    Imphenzia: How Did I Learn To Make Games:

     
  3. Almost73

    Almost73

    Joined:
    Apr 28, 2023
    Posts:
    8
    I do not know what is with that answer but you sound like an AI.
    The main reason that I am looking for help here is because I didnt found anything online for what I need.
    And to be more clear about what I want, is to be able to interact with an NPC, chose the skin from a drop down list and immediately change my character sprite, my question was how do I implement that in a efficient manner. Its just as simple. The reason I didnt mention anything about inventory, equip possibility, item resistance, etc, its because it will not exist in my project. If you want to be of help to someone here, at least please read the whole post and then reply.
    Thank you!
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,736
    Thanks, appreciate that. I'm not an AI. I'm a professional software developer.

    I posted the above because you are agonizing about possible complex multi-animation movement designs when you haven't even started writing the software.

    Put a stake in the ground: get a paper doll character selector up and running.

    Go write the software. It won't write itself.

    You may find that simply writing a paper doll simple character system involves such a prodigiously complex amount of work (see above) that you give up and say "Well, a simple paper doll is all I need after all."

    If you fully implement a paper doll system and run into something it cannot do, then come back and post your issues.

    In that case you will have concrete code that we can all look at and contribute to a solution for you: "You might consider changing this part to do X and Y instead of just X..." (for example)

    How to report your problem productively in the Unity3D forums:

    http://plbm.com/?p=220

    This is the bare minimum of information to report:

    - what you want
    - what you tried
    - what you expected to happen
    - what actually happened, log output, variable values, and especially any errors you see
    - links to documentation you used to cross-check your work (CRITICAL!!!)

    If you post a code snippet, ALWAYS USE CODE TAGS:

    How to use code tags: https://forum.unity.com/threads/using-code-tags-properly.143875/
     
  5. karderos

    karderos

    Joined:
    Mar 28, 2023
    Posts:
    376
    use the animator only as an engine to decide what clip to be shown

    then use a script to detect the current clip and current frame of the animator

    finally set spriterenderer.sprite to the correct sprite for a given skin

    use only 1 animator, and the animator cant be on the same game object as any sprite renderer

    it will be wise to setup an array structure for your sprites like skin[a].animation[x].direction[c].frame[d]
     
    Almost73 likes this.
  6. Chubzdoomer

    Chubzdoomer

    Joined:
    Sep 27, 2014
    Posts:
    132
    It's possible I've misunderstood your situation/requirements, but are you by any chance familiar with Animator Override Controllers? Those make it easy to give something a brand new look while retaining the same exact Animator layout/logic. In your case, all you would need to do is swap out your character's current Animator Controller for the desired Override one.
     
    Almost73 likes this.
  7. FaithlessOne

    FaithlessOne

    Joined:
    Jun 19, 2017
    Posts:
    320
    Also Sprite Library Assets/Variants may be an option for skinning when using sprite based animations.
     
    Almost73 likes this.