Search Unity

How to create Dynamic Sprite For Characters in 2D.

Discussion in '2D' started by dullman, Aug 2, 2016.

  1. dullman

    dullman

    Joined:
    Jan 20, 2015
    Posts:
    29
    Hello i have a question in last week i have played some time in rpg maker mv and created a dynamic sprite system where the sprite of character changing with equipment (From naked with none to fully clothed with all slots filled). In MV it all seems pretty easy i only need to create single bitmap with all frames and direction from several pieces, but here in unity I would need to create a different sprite object for every single frame, which seems to be overkilling for memory especially if i want in game to have fully customization of PC and random look of NPC. So is there a way to tell unity that for sprites he need to use a single dynamically created bitmap, which during runtime he would recreated, slice and use it in animation when needed??
     
  2. Hyblademin

    Hyblademin

    Joined:
    Oct 14, 2013
    Posts:
    725
    If you're asking about sprite sheets, then yes, Unity supports sprite sheet slicing. Import the image, and in the import settings, set the Texture Type to Sprite, and click on the Sprite Editor button.

    See here for more information.
     
  3. dullman

    dullman

    Joined:
    Jan 20, 2015
    Posts:
    29
    Hmm it seems like you didn't understand my question, possibly because i wrote it badly, but what i ask is there any way to to import bitmap, slice it and use in animation during runtime??
     
  4. MarcHewittDev

    MarcHewittDev

    Joined:
    Nov 28, 2012
    Posts:
    8
    Towards you latest reply, technically yes you can do that at runtime, but I don't think that's what you want as that's more for the player to upload their own sprite sheets.

    Your first post makes complete sense on what you want, and that is one of the super powers of RPG Maker. It's quick sprites for rpg games. What I read from your first post is you simply want a user to be able to "build" their own character off several different sprite sheets of single images you've created, and have that character changed as they change gear.

    It really depends on the game, the complexity of the animations and sprites. If it's an RPG maker clone, just use rpg maker as the work isn't worth it. But if you want todo fully animated characters with changing states and abilities then your best bet is to learn about 2D Bone Animation ( https://www.toonboom.com/community/success-stories/ben-halstead good article, I don't use their software though) and understand that Unity3D is a Component Based Game Enginge (and what that means)

    If all you want is basically "Slots" that a sprite can be put into as you describe in your post then the best example I can give is if you have a player, with the ability to get a sword, outfit, and jetpack. Then you'd need 4 prefabs, each with their own sprite render.

    The player would be located in the world, and the other 3 prefabs would be created dynamically and added to the player as needed. The different sprite sheets would also be loaded dynamically for "type" of outfit / sword / jetpack so for outfit "Naked" I'd have a sprite sheet of all the naked stances, for "shirt" I'd simply change which sprite sheet I'm using on "outfit" to the shirt sprite sheet.

    If he equips the sword, you create and add the sword prefab to the player prefab in the scene. The prefab contains all "Sword" related code and allows swing animations to occur. Same thing with the jetpack.

    It'll be allot more to learn to make it work in unity then RPG maker, but that's simply because that's one of RPG maker's super power, quick simple sprites. Unity's is being a very flexible Component based 3d & 2d game engine, that if you have the technical skills you can make it do what ever you want it to do (like these guys at unite 2016 ripped apart unity to make a cross platform pvp mmo
    )