Search Unity

Customizable character workflow in untiy

Discussion in 'Animation' started by libra34567, Feb 1, 2022.

  1. libra34567

    libra34567

    Joined:
    Apr 5, 2014
    Posts:
    62
    So whenever I get characters assets from assets store or provided by freelancer.
    I often seen they have everything under one root. like shown in the screenshot.
    upload_2022-2-1_22-32-1.png

    I understand this is to ease the cuztomization of the characters with different hats/tops.
    But I'm little concerned with memory issue. As inactive gameobjects could also take up memory. And in our game we often have 200~300 of those characters fighting arround.

    The requirement from dev team are as follow:.
    1. Supports up to 300 characters in the scene at the same time
    2. Character is seperated into two parts: hats and body. We need to allow the hats and body to be swaped during runtime. (Allowing player to customize their characters). Currently all of the bodies are animated. Some of the hats also are.

    I wonder what should I do to best fit those two requirements?
    I tried to add body and hat to the character then assign the root bone runtime but it doesn't seems to work .
     
  2. bobadi

    bobadi

    Joined:
    Jan 3, 2019
    Posts:
    670
    I think you could delete unused objects and they won't take up memory.
    should test this.

    if the objects use the same texture, you could easily combine them.
    if they use different texture, new texture map atlas should be created.

    here's an asset that does that: skinned mesh combiner

    if you want swapping then you need all swappable objects of the character,
    to select/switchOn the ones the player wants and switchOff/delete the ones the player doesn't want.
     
  3. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    But did you actually measure it? Did you? :)

    1000 inactive gameobjects are unlikely to be doing anything bad with memory, especially if these are prefabs. With addressables you can also keep the textures out of memory until you need them (or just enable mip streaming and call it a day).
     
  4. libra34567

    libra34567

    Joined:
    Apr 5, 2014
    Posts:
    62

    Thanks much for the optimization tips/tool. Will test those as sugguested

    In my case we are gonna need all the swappable objs of the character. So I should probably keep them all :)
     
  5. libra34567

    libra34567

    Joined:
    Apr 5, 2014
    Posts:
    62
    Aha thats perfect !, In that case I will just be leave them as it is, on top of that do setup mip streaming as you sugguested!

    Thank you very much, problem solved :)
     
  6. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Yeah but you must make sure you measure it via the profiler.
     
  7. libra34567

    libra34567

    Joined:
    Apr 5, 2014
    Posts:
    62
    Just did!, tested 1000 characters without having their hidden objs removed, and another 1000 character with hidden objs removed.

    Seems like 1000 * 10 (10 unused gameobjects per character) didn't do anything noticible to the memory. With inactive gameobject test case the GC is slightly higher (~5%) which is totally managable in our case.

    Results are as follow
    Case A
    upload_2022-2-4_1-19-56.png

    Case B
    upload_2022-2-4_1-20-17.png