On Blender > Unity workflow, and character customization methods

I’d like to run what I’m about to do by you guys just in case I’m doing something dumb here, hehe.

What I’m trying to accomplish:

  • Player, NPCs, and enemies using the same animation rig
  • Customizable skin, hair, clothing and weapon items
  • All nude, clothing, weapons, hair etc objects in separate blend files and unity prefabs
  • Combine child meshes in each character game object at runtime for 1 draw call or close
  • Optimized for IOS.

So at the moment I have my male and female character nude meshes in separate blend files, and I imported them into unity and made prefabs of them. I made alternative materials for different skin colors.

My next move is to make an animation dummy blend file which will house all animations, so I can just keep adding onto that file at my leisure with minimal prefab retreading. I’ll be retargeting the clothing/skin meshes of each player/npc/enemy to this rig. This seems to be the way to go if you’ve got a lot of gear, since I should be able to just mount them onto each character GO at runtime kinda like a mr potato head… rather than just having them all in memory on each character GO and turning them on or off. To prevent clipping issues, I’ll have different versions of the nude character mesh that is missing parts that are replaced by clothing.

When I type that out and read it, it seems solid. I wonder though if I’ll be thrashing the ram by loading in and cobbling together characters like this. I intend to have an npc/enemy pool but when I use one I’ll be changing the clothing / weapon they’re equipped with, so theoretically… do you think I’ll run into trouble this way? Or is there anything else I should be considering with this approach?

2 Likes

Regarding character texture atlases, I’ll be aiming for about 10 total which will house the UV’s of all character and equippable item meshes. I have 4 right now from duplicating the skin atlas and making different skin tones, and there is plenty of room left for lots of equipment and clothing that I’ll be taking advantage of.

I want a lot of mayhem on the screen at once, so I’m trying to keep draw calls as low as possible. :smile:

Your method sounds nicer than what I ended up doing. For my characters, I have all the customizable parts (including gear) in one .blend file. Each part is named very particularly to group them into appropriate categories (body-male-01, head-female-02, hair-male-12, etc).

I reference that model in my CharacterGenerator, which reads the model on initialization and determines the number of options for each feature. When I instantiate a character, I remove all the feature object that don’t belong to that character, while disabling the gear options unless they possess that item.

To change colors of hair and skin, I shift UVs around as described in my thread here (near the bottom). This works for me since my UVs are each solid colors, but it may not work for you. In order to select the appropriate color, the CharacterGenerator has a series of arrays indicating acceptable index locations of the texture atlas.

The one “gotcha” I do want to point out is to make sure you never reference the mat property of an object, but rather always the sharedMaterial. Even grabbing the name of a material using mat will cause a new instance of that material to be created, and you’ll lose dynamic batching on it.

2 Likes

Good info! Ok, checking out the thread you linked because I’ll also be going for solid colors, and just have the UV broken up for the different chunks of color (It’s low poly anyways so it should be ok I’d think).

Thanks for the material info. I haven’t implemented this yet and hadn’t really looked into what methods there are for doing it, but I’ll mark that down as a critical topic for when I tackle that. Thank you :slight_smile:

So, I went looking at shared materials just now, and Unity seems to suggest doing the opposite: Unity - Scripting API: Renderer.sharedMaterial

Absolutely! And please keep us updated here on your progress and success with attaching objects separately. I’m not so far along that I’m not willing to totally redo how I’m handling equipment, so if your way seems better, I may switch things up.

I should have clarified. You’re not actually changing the material in our case. You’re shifting UVs of the mesh, so all your different meshes can use the same material while looking different. Since materials are what gets batched, not meshes, this is exactly what we want.

1 Like

Will do. I’ve been learning 3d modelling/rigging/animating skills, unity, and C# scripting from scratch for 7 months so I’ve had plenty of time to google how other people are accomplishing the things I’ve mentioned… and it’s a lot to take in for a greenhorn, but I think this is the best solution for my needs. You should see the stack of papers with notes, and also the mess of text files with links and tips and general spitballing summaries I’ve collected trying to get my head around this project. At this point, my biggest stumbling block is trying to remember all the stuff I’ve learned, hahaha.

Like anything, keep doing it, and eventually it’ll become second nature. Good luck!

1 Like

Yep! I’m getting there, and it’s been a fun ride. If I can get the workflow hammered out over the next few weeks I will be very pleased. I’m really anxious to move on to playtesting, but it’s still a ways off yet.

Well, made some progress today… got the animation dummy and male & female base meshes separated and imported to unity, made prefabs of each. Next step is to rig up the player avatar using the dummy, disable that mesh at runtime and then make it load in the male mesh. Had to import it twice to fix a mistake, and it was so nice to not have to reimport the male & female mesh with it and reset the shaders, etc. I think this is going to work great. :smile: :smile:

Boom.

So, the short answer is yes this works and yes it’s a great idea. What I do:

  • Model piece of clothing in my avatar file in blender
  • Append piece of clothing & skeleton into another file, so it’s on its own, then import that to Unity
  • Make a prefab out of it
  • Instantiate the character avatar mesh (only skin), and the clothing mesh into your player game object
  • Make an array of the bones in the avatar, and an array of bones on the clothing
  • Change bone array on clothes to match array on avatar. Then remove unused bones on clothing
  • Disable parts of avatar you’re not using.
  • Dance around the room in my jammies cause it works.

Disclaimer: Still haven’t playtested this to address my concerns about memory thrashing, but hey it works.

1 Like

I also managed to get this working with it, and IMHO it comes off quite polished. Just gotta be smart modelling and color choice. Thanks for the help, man.

1 Like

Don’t leave us hanging! Post some results!

1 Like

Howsabout a pic
The hands, face/neck, and legs are from the avatar file, and shirt/hair/beard/eyebrows all from separate files. He’s got a backpack too but you can’t see it really. All spliced together, transfers bone weights properly, color customizable skin and hair, and any items I wanna do, and then combine it all into one mesh. The character is taking up 2 draw calls, but ALL enemies and anything else I decide to use with the color atlas will share those same 2 draw calls. That means no matter how many enemies I add, I get no extra draw calls. All at runtime. Achievement unlocked.

Unfortunately he has no junk, but that will be resolved when I model him some pants. :smile:

I haven’t progressed the engine far enough to playtest yet except in the editor, so no results there for a while. Been checking things off the list though.

1 Like

And as a side bonus, I can create character equip meshes at my leisure instead of having them all imported to unity at the same time. Same goes for animations, so it minimizes retreading every time I add something.

Seems like you have a great handle on the process your using, glad to see you making progress.
I’ll definitely be pinging you about your workflow/pipeline when I get to a point where I need customized characters.

Are you setting this up for the players/users to have selectable swappable clothing/armor - kinda like Skyrim or any similar type game, character select screen, inventory swappable items/clothing?

I’m sure your aware - but I’ll list some threads I’ve found useful on the topic.

There is also this - http://forum.unity3d.com/threads/stitch-multiple-body-parts-into-one-character.16485/
though I’ve not seen very much discussion regarding animation retargeting using this method, however it seems like a workable solution others have used.

Watch out for optimizing mesh and rig - http://forum.unity3d.com/threads/optmize-hierarchy-of-a-generated-skinned-mesh.340876/#post-2587424

Ubrin - http://forum.unity3d.com/threads/character-creation-system-relesed.256740/
Of course UMA - http://uma.unity3d.com/wiki/index.php/Content_Creation

And for any type of morphology for the characters I’d strongly suggest (based on research only not hands on) this tool -
http://forum.unity3d.com/threads/wip-ucc-create-custom-morphs-and-modifications-on-any-model.342519/page-3

1 Like

Thanks for the links! Yeah it’ll work like ye olde Skyrim and other similar games where you build a character, hopefully morph him/her, and then dress them up how you like in the game.

I don’t really understand what the deal was with optimizing mesh and rig though… I suppose I dont really know what is meant by that, specifically. When I run my game, it instantiates bodyparts into the character, swaps the bones with the main rig and disables all other bones (will probably be deleting them instead, eventually), and then stitches the meshes together into one. No errors or anything, what am I missin’?

OMGosh, that mesh morpher is phenomenal. I still haven’t looked at blendshapes in blender for body morphing, cause it seemed really confusing… but this thing might be exactly what I need. Thank ya

Little bit of testing with mobs to see what happens to the numbers… It’s a simple scene but I’m very pleased to see that it had zero impact on the framerate on my iMac. No idea how an ipad/iphone will react yet though.

It doesn’t look awesome yet, but now that I have finished these tasks and have a solid idea what I can accomplish towards my art direction goals, I am confident that it will look kickass when I’m done. Huge grin up here. Huge grin.

1 Like

@CrisisSystem I seem to have missed this thread a couple of months ago, so it may be sort of late, but I wanted to leave my resource here just in case.

When I was setting up my character customization from Blender to Unity, I also wanted to separate the rig, animation and model files, to prevent unnecessarily loading unused models into memory. As you can imagine, with more attachments that you have for your characters, the more memory it will consume. I’m not sure how your solution manages memory, but here is the solution that I came up with:

The advantage of this solution is that it loads models directly from disk, and binds the model to the rig during runtime, not design time.

Also, as for authoring from Blender, you’ll notice from those articles that I authored them in layers in Blender.
Far from ideal, but the problem that I was having is that I couldn’t figure out how to link a Blender file containing a mesh to a Blender file containing a rig/animation. The option to link files is there, but for some reason, I just couldn’t get it working for a rigged character. It usually put my Blender file in an unusable state. If you found a way to do this, I’d like to hear about it.

But one of the keys to getting my system working was to have a proper export pipeline from Blender to Unity. My exporter splits the Blend file into separate FBX files to be imported into Unity. One for rig/animations, and another for all the costume models.

The result of this system can be seen in my game Horde Rush in my signature below.

I hope this is insightful to someone, anyone. I apologize in advance if this is sort of what you are already doing, as I’m about to head out for a long road trip, and just skimmed the posts. I’ll re-read them later more carefully though.

2 Likes

And for fun… finally managed to take the FPS down a few notches by adding a 2nd runtime light and a crapton of mobs.