How to create my own character customization system & mmog server?

Hi,

I’m new to Unity and C# but quite comfortable with writing a software. That being said, I’ve set out to create a Second Life like game and a supporting framework to extend it.

I know it will be a tremendous task to do, especially when I’m the only person for the job and I can spend 1-2 hours a day at most. But for some reason, I’m intentionally trying to ‘reinvent the wheel’ in as many cases as possible without relying on purchasable assets, so I’ll be creating everything I need, including character and camera control, inventory, attributes, chatting, UI systems and all.

I know how crazy this might sound like, so you don’t have to remind me about it :stuck_out_tongue:

So, my question is what would be the best approach to design a customizable character system, and networking API to be used in such a game?

For the character system, I’m thinking about using base models from Manuel Bastioni Lab and write my own API to apply morphs in game, but I’m not too sure what would be the best approach in implementing it.

Should I rely on blendshapes to apply morphs? And if so, what would be the best approach to create them? Due to license restrictions, reverse engineering it or migrating its source code is out of an option. So, maybe I should create different characters in Blender with that tool, and somehow merge them at vertex level to create a shape key?

As to the networking API, I’m planning to write the server part in Scala/Akka. I know that in this case, I won’t be able to use some of Unity’s built-in multi player features, like physics simulation, or prefab support, and etc. But aside from them, are there any possible road blocks which would make the approach not viable?

And if it’s something feasible, what networking API should I extend to support it (in abstraction level)?

Thanks!

There is an inexpensive solution for customizable characters on the Asset Store in the form of UMA.

Thanks, I know that there exists UMA and MCS but I just want to do it my way :slight_smile: And I think I’m also aware how much work it would take to create something like that. But I just want to know what would be the best possible approach to make such a system on my own, using Manuel Bastioni Lab models.

Instead of “best possible approach” a better idea would be just try any one that works.

Character customization can be done two ways: Model is assembled from preprocessed pieces, and after customization corresponding pieces are attached to the character’s mesh. (Reattaching a skinned mesh is a bit cumbersome, by the way)

OR, the character’s model can be made by merging individual pieces into one mesh unique to character (this is how UMA works, by the way). This approach will result in lower number of drawcalls.

On top of that character bones can be scaled or their positions could be adjusted a bit to accomodate different proportions. In this case it is possible that you’ll need to build custom avatars for characters in code and utilize mecanim humanoid retargeting.

(See: https://docs.unity3d.com/ScriptReference/AvatarBuilder.BuildHumanAvatar.html )

And that’s pretty much all there is to it.

3 Likes

Thanks for the tip! But I’m afraid I’m still a bit unclear as to how can I actually change shapes, rather than just dimensions of each body parts.

I thought that the API you linked is something I could use, if I’m to make the created character to correctly move according to mecanim animations (including IK), not something usable in shaping the mouth, or nose slope, and etc.

And I guess I can understand what you are saying is I can prepare various different types of heads, for instance, and then merge them in runtime. But wouldn’t it limit the variety of the created models? For instance, I could maybe prepare 10 different eyeshapes beforehand, but what if the user want to also change the eye height? Wouldn’t it lead to almost unlimited combinations, if I were to create something like Second Life’s character customization system with this approach?

I haven’t yet used UMA but I briefly looked into MCS, and I thought it’s basically some optimized Daz3D models with their morphs translated into blendshapes. If UMA really uses that mix-and-match approach to customize their characters, is there any pros & cons between the two approaches?

https://docs.unity3d.com/Manual/GeneratingMeshGeometryProcedurally.html
^^ Read that. Construct a mesh based on several templated mesh. Parts can also be adjusted by blendshapes, bone positions, etc. Skinned meshes (your characters will be skinned meshes) are more difficult to handle, because you need to deal with bone transforms and bone weights.

You either attach area surrounding the eye to a bone and modify bone position, or generate the face mesh based on set of parameters, in a fashion similar to procedural geometry. It depends on whether you want ability to morph faces while the game is running, or only during character creation.

Attaching parts to a skeleton:
Pro: Simple to prepare and implement.
Con: More drawcalls.

Merging models into a single mesh.
Pro: Less drawcalls.
Con: More difficult to prepare and more difficult to implement. Can also take more memory, especially if you also blend textures together.

Maybe I wasn’t really clear when I tried to describe what I want to know. Sorry if it is the case!

I suppose I already have some understanding on how I can generate or manipulate a mesh in runtime. So, I’m more interested in the details, like let’s say we have a certain morph slider in MB’s Blender plugin which changes shape of the eyes. Then what would be the optimal approach to implement this feature in Unity?

For now, the only way I can think of is export two different models, and compare the deltas of changed vertices to create a shape key. Then I can export the model in .fbx and I’ll be able to adjust the eye shape using the converted blendshape.

Probably, I’ll need a different approach for dimensional changes, like adjusting length of legs. But I can’t imagine any different approach for morphs for now.

From what I read above, it seems that I can create number of different meshes for eyes (with the exact same topology) and merge them in Unity later. I can understand that, but what about such morphs which requires smooth transition, rather than let users to choose between 2-3 alternative shapes?

Maybe I could use additional bones in design time, but aren’t there such morphs which can’t be easily be implemented that way, like adjusting thickness of eyefolds, for instance?

Of course, theoretically I can do whatever from a script to adjust positions of every vertices needed to do that. But is it really the way they do? I mean, devising some algorithm to calculate proper positions for each vertices for all the morphable shapes? I don’t know how to programatically change a nose shape from a straight one to a crooked one, for example. So I thought there must be better ways to do that, like using a blendshape, for instance.

Probably, I should have done some research to understand how UMA or MCS does it before I post a question. Anyway, I’d much appreciate if anyone can have any other tips, or guides for the issue.

I suggest to forget about “optimal”, because in order for something to be “optimal”, you first need a use case. (genre, amount of detial, number of people in the scene, etc).

Either way.

Blendshapes.
(For example: https://docs.unity3d.com/Manual/BlendShapes.html )

Unity supports them. You can either keep blendshapes in final face (more computationally expensive), OR you could “bake” the geometry into one final mesh (more scripting effort, less computationally expensive).

Unity should support blendshapes out of the box, without exporting separate models. Either *.fbx supports them, or *.blend file import supports them or both of them.

You could probably setup the whole “Character room face rig” in blender and specify position limits for bones via animation clips.

You need to familiarize yourself with blendshapes and test them in unity. The bulk of your response revolves around you not (most likley) knowing that blend shapes/shape keys/whatever else they’re called are a thing and that they’re supported in unity.

I’m sorry, it must be my limited English proficiency that prevented me from expressing my ideas clearly. I already know how to import blendshapes from an external model, and how to apply them in game.

What I meant by ‘exporting two different models’ was, to create a single shape key (I didn’t call it a ‘blendshape’ yet, because we’re still in Blender) I need two different ‘states’ of a single mesh group. MBL plugin has morph sliders, but once you hit export, it’s just the end result without any shape keys, so I need to create them by hand.

What I really wanted to know was the approach I described is a viable (if not optimal) option to create a character customization feature comparable to those in such games like Second Life (smooth transitions of each morph targets, and etc.), or is there any better way to do that.

But anyway, I really appreciate you for answering my question.

Morph target and bone based deformation can be used at the same time. Also You can do a lot with just bone base by smart position of the different bone (even lips and noses). There is a youtube channel that have experimented with a deep bone base solution inspired by UMA but with more sensible bone placement, look for craigperko’s channel and look for “avatar” in its video (you can see him experiment and how it does it, he use unity and had to do a lot of import).

It’s also notable that you can use solution where you have a character generating meshes and then bake the modification into another singular mesh for in game character to get rid of the adjustement bones and improve performance by reducing the number of transform (which is an option in UMA).

Generally if you want the best results, you would use a bone base generation with mesh baking and have morph has corrective shapes to help subtle volume deformation.

1 Like

I suppose I have some starting point now, at least :slight_smile: I’ll check the YouTube channel you mentioned, and try to experiment with both bone and blendshape based solution later.

Thanks much for the help!

P.S.: Could someone give me any tips on the networking part, please?

1 Like

How did it go?

Not good apparently. Lol.

Read his signature. He’s no longer using this game engine. I doubt he’s even logged on here since then.

Over-ambition is a constant source of frustration in this medium. Anyone with a modicum of experience can tell you that a fully-featured character customization system is a nightmare to develop. A single developer working on their own should scale back their target to something more manageable.

In this case, I would have recommended stepping back to a 2D-focused character system. You could start it off with low-resolution sprites, and later step it up to a more flexible system using quads and higher-resolution assets. Starting off with 3D models is insane.

4 Likes

Hey! I have a solution for this in 10 steps.


Step 1

Create a basic(default) character for your game. This will be used as our parent object. I would recommend exporting all your 3d models as FBX models as they take up less space, and are smooth to work with in game engines like Unity, Unreal Engine etc., (we’re using Unity here though as it is better than Unreal Engine)

Step 2

Create all the children objects (for example, a t-shirt, a cap, a mustache etc.,) individually. Export them as FBX Models.

Step 3

Export the 3d Models into Unity. This is pretty simple - right click on your Assets folder and click on ‘Import New Asset’ and just export all the models. Now, you might notice that the models don’t have textures. Don’t worry, this is an easy fix. There is a separate tutorial for that here. So I recommend that you read this tutorial first, repeat it in Unity and then come back here.

Step 4

Now, drag in your default model into your Unity scene. After that, just drag in your other child models into the scene, and make sure to parent them to the default model. Now, change the positions of your child models so that they are in the right place, in the right scale (you don’t want a giant mustache in the character’s chest, do you?).

Step 5

If you have a lot of models, then your prefab must look like a monster right now. Don’t worry, we’ll fix it. Just disable all the other children and then you have your good old default model, looking all handsome/beautiful. Drag and drop your prefab onto your assets folder - you don’t wanna lose that.

Step 6

Create a character customization menu with buttons with names/images of the outfit. Also include a raw image with the rendered model of your character. There’s a tutorial for it right here.

Step 7

Now, create an empty game object and parent it to the default model. Now, add a new script to it and open in in Visual Studio.

In the script, under your class reference, create some variables - one for each child/outfit. (I will use angular brackets to show that your value goes here)

public GameObject <variable name>;

If you created your variables, then save your script, go to unity, and then drag and drop your child objects into the specific Game object slots (these are a reference for your variables).

Step 8

Now, we will create the code to our buttons. Open the script from Step 7, and remove both the void Start() and void Update() methods. Now, copy paste this piece of code here and then customize it. Do this for each object.

void <function name>()
{
        if(<corresponding variable>.SetActive(false))
        {
                <corresponding variable>.SetActive(true);
        }
        else
        {
                <corresponding variable>.SetActive(false);
        }
}

Step 9

Finally, it’s time to add our functions to the buttons. Select the corresponding button, and then go to On Click() option on the button, then click on the + icon. Now, you must see that a new menu-like thing gets created. There is an option called None (Object). Drag the empty game object that your script is sitting on onto the None (Object) option.

If you do this right, a dropdown called No function is enabled for you. Click on the dropdown and select your corresponding function. Do this to all other buttons as well.

Step 10

Test it! See if you have any bugs with the code/models, or problems with the renderer etc.,

Once it is all done, your good to go! Ask your friends to test it out too, and then ask the some suggestions.


Hope this tutorial helps you. If you want me to make it as a Youtube tutorial, then just let me know.

4 Likes

Lol, I just realised that this post was made 4 years ago :smile::smile:

1 Like