Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Question A beginner game design question: what's the better way of setting up these similar sprites?

Discussion in 'Scripting' started by bullettea, Apr 13, 2023.

  1. bullettea

    bullettea

    Joined:
    Oct 24, 2019
    Posts:
    29
    So I have a game where you plop down a dozen types of workers (woodcutters, miners, builders, etc.). All the woodcutters share the same sprite, all the miners share the same sprite, etc. There will most likely be a maximum of 40 of these workers on the screen at a time.

    All of the different professions are similarly sized, with similar sized body sprites. I was able to put all of them into one .psb file and put them in the skinning editor, using the 2D experimental sprite swapping package (Unity 2019). Their body parts and labels are organized so you can change the sprite object on the fly and select any worker type through code. They all share the same bones and animations. (Used this tutorial:
    )

    The question I have:
    • should this be just one "worker" prefab that I can instantiate in the game view, that is affected through scripts and scriptable objects (by setting them the sprite resolver to the appropriate category and label) This seems the most flexible to me, though I wonder what the overhead is on having 40 of these in game view and the fact they all have each other's sprites (though 39 of them are inactive on a given sprite object.)
    OR
    • should I make one "worker" prefab and then dozen prefab variants instead? I guess the variant would still have the sprites for the worker types, since I can't seem to detach them from their bones. Or not sure how to do so cleanly in a prefab variant since Unity seems to read the PSB file as a single entity.
    OR
    • should I make each type of worker a separate prefab with ONLY the sprites for that worker? What if I want to add an animation in the future...will I have to do that with each separate worker type?

    Any advice appreciated for this beginner, thank you.
     
  2. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,533
    This doesn't address your main question, but if you're not already aware there's a 2022.1 performance improvement [more] using Burst and Collections. If you have 40, then it may be necessary.
     
    bullettea likes this.
  3. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    1,042
    Any of those choices are fine so pick whatever you feel is easiest to work with at this point in time. If you later find you need more flexibilty then you'll be already armed with experience and knowledge of precisely what you need and why, something you're much less likely to guess 'correctly' at this stage.

    One thing that seems pretty certain is that with only 40 of these you have almost no worries about performance issues of an architectural nature so let your choices be made by what is easy and fast to work with. If you do have framerate issues they will likely be due to something other than just too much raw data being processed.
     
    bullettea likes this.