How to do Character Customization! (4 Methods, Unity Tutorial for Beginners)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome i'm your code monkey and here let's handle some simple character customization this one is a topic that has been requested quite a few times and just a while ago i was browsing some assets and i found a pack that would be perfect to demonstrate the system in this video i want to cover the various methods from the simplest to the more complex showing you what fields you need to change and how there are actually quite a few tricky things with doing this especially with the funnel method so by watching this full video you will hopefully avoid the frustration that i went through when i researched this topic if this video helps you please hit the like button it really helps out this was actually quite a bit more complex than i was anticipating this topic is also pretty dependent on how your assets are set up so for this demo i picked up three characters with three different setups from three different asset packs so hopefully you can learn how to do this with whatever characters you have do you want to learn unity blender and programming patterns then check out my curator code monkey bundle with a link in the description this is a collaboration with gamedev tv all of their courses have the highest rating possible i got in touch with them to specifically select three courses to make a nice complete bundle to take you from beginner to advanced i chose their ultimate unity 3d course this one will teach you both unity and c-sharp both starring complete from scratch then the blender 3d modeling course i picked this one up myself a few months ago and i've learned a ton thanks to it and the final one is a more advanced really interesting programming course all about programming patterns it's excellent for helping you massively improve the quality of your code which in turn helps you make better games faster i chose all of these cores myself to really give you a nice path to go from beginner to advanced the bundle has a really nice discount so check it out with a link in the description okay so there are several ways to handle character customization the simplest possible is with these two methods first just change the material and texture this works for a basic reskin although a texture includes anything so it doesn't have to be just literally changing the skin color depending on how your character is set up you can change the color of the mountain armor or whatever else use the material that you're swapping the second simplest method is by changing the visual mesh this will change the entire physical shape of the character i actually covered just this method in detail in another video how you can easily swap meshes while keeping the same animations so with just these two methods you can already achieve quite a lot of customization variation and then building on top of those you have two more methods for adding parts to your characters you can add parts using mesh renders or you can add parts using skin mesh renders the skin match renders one is a tricky one it can be quite hard to understand why it's not working now in this video i'm focusing just on the basics for how all of these methods work just showing you what fields you need to change and where you need to spawn the objects i'm thinking i might do a second video after this one building upon these basics with an actual working system something to handle all the parts maybe include a safe load system ui buttons and so on let me know in the comments if you'd like to see that follow-up video but first let's start off simple so here is my demo for the essence like i said i found an excellent asset pack just for this topic it's the modular character pack by cinti studios and right now they're actually running a spring sale on their store everything is at half price including this pack this pack contains over 700 unique parts so with just this one pack you can create a near infinite amount of characters so definitely check out this pack with the film link in the description as well as everything else that is currently on sale on the cinti store this one is the last week of the sale everything is at half price and the western pack is at 70 off if you're a fan of their style just like me you can find asset packs for whatever game you're currently working on so over here i have this character from that pack then i also have another character here this one is also by cynthia studios but this one is from another pack this one is from the battleground pack and finally i have over here another character this one is from the free unity star assets this one is a really awesome free asset with first and third person controllers made official by unity i cover them in detail in another video if you want to learn more and the reason why i picked up these three different characters is because making a character customization system is very much dependent on how your ads are set up so by showing it working with three different characters with three different setups you will hopefully learn how to apply to any characters you have over here on the first character this is the one from the modular characters pack the character is set up with multiple skin mesh renderers you basically have a different one for each body part so all the hair objects are all of them over here you can enable and disable them to swap them out then over here a bunch of face coverings there's a nice hat some other one and so on then for the various torsos all of them with different armor different things and finally the setup for this one inside the skeleton it also has a few pre-made objects for example here the hips attachment so a few objects that were pre-made to place all the extra parts there's a back attachment cape chest and so on so it has all of these extra objects then on the second character over here this one is from the battle royale pack this one is made up of a single skin mesh renderer so just a single one for the entire body just one material and then this content is all pre-sanded just has all the bones so no attachments and finally over here the character made by unity this one is also composed of a single skin mesh render although this one does have multiple materials and then also has a pre-regular skeleton okay so those are the three characters and the slight differences with how they are set up now like i said the first method is just swapping out textures one of the reasons why i love cinti assets is because their assets usually include multiple textures which you can easily swap so for example on this one on the modular characters pack this is the one that is set up with multiple skin mesh renders so on this one if i swap out the material so swap out for this one or this one and as you can see this one changes the skin color although again it depends on how the character is set up and with this one this one is set up of multiple skin mesh renders so that means that i don't need to change just one material i have to change them all so for example over here you can see the skin color is different in the face and the hand so i need to go back into the hands so i was for the other one and so on and yep now it is indeed in uniform so yep there you go with this you see some basic character customization just recoloring then on this other character also made by cindy studios this one is the one that has just a single skin mesh render and on this one recoloring it's also the same thing so once again it includes various meshes and i can just swap out the material and i get a different one with different visuals and finally on the last character made by unity it's the same thing just swamp out the material to change the color this one doesn't actually come with any prebuilt texture variations but you can just go into the main base textures and over here just draw over them and so on alright so that's the simplest method just swapping out the materials like i said in this video i'm focusing just on showing you what fields you would need to change so for this method you can easily make a script with a reference for a material and just swap out the skin mesh random material for the second method swapping out the mesh itself that one i actually already covered in detail in another video basically you need to swap out the mesh swap out the material change the skeleton and assign a new animator avatar i don't want this video to be too long so go watch that other one if you want to see how to do that and some common issues with that method and finally let's look at the more interesting part of a system like this adding things on top of your character so adding armor hair capes and so on in order to do this like i said you have two methods you can either use regular mesh renders or you can use skin mesh renders there are some pros and cons to both and again it also depends on how your assets are set up this character here from the modular pack has both those methods so let's see first using skin mesh renders the asset actually comes with a bunch of pre-made characters so all of these are pre-made using all the various components that are included and if we look at the character we can see that somewhere is set up in all of the various parts each of them over here is using a skin mesh runner and you can see it's using a different mesh and for the different parts they also got a different root bone maybe a different material and so on so in this case in order to do character customization with these ones you really just enable or disable game objects so just making a simple script talking out that one for that one and there you go it changes automatically this one is especially easy to do if all of the parts are already included in your prefab just like with this character so over here you could make a very simple script just to enable or disable all sequentially going through all the children and so on so this would be super easy to use so yeah if you're looking to make some character customization i can highly recommend this pack now of course there is a cost to having a character prefab with tons and tons of parts even if they are disabled game objects so if you go ahead with this method definitely make sure you only use all the parts in the character customization screen and then once the player has customized their character in the end then just do a recursive cycle through all of the various parts and just destroy all of the game objects that you're not using if i end up making that second video i'll definitely cover that process now let me cover the mesh render method before i talk about the common issues with skin mesh renders with the mesh render method it's actually super simple so as i said this character pack comes with both those methods and by the way if you want to know where all of these skin mesh renders exist well they're all inside the mesh so as you can see over here all of the various body parts on the built-in mesh so here is the modular character's mesh and has all these tons and tons of things so that's how you apply it using the skin mesh render method for the measuring method then you need objects with just the mesh render and for that this pack also has that so over here all of them as inch individual objects so each of those is a separate prefab for a separate part separate thing so over here a bunch of arms a bunch of eyebrows facial hair and so on now as to how you use a regular mesh render in customization it's also super simple what you need to do is find the bone where you want to attach the part so let's look over here into our skeleton and for example over here inside the bone inside the neck we've got the head and we've got a head attachment then just find the part that you want and simply drag it as a child of that bone and yep there you go that's really it as the bone moves along with the animation this object moves along with it now obviously again this will depend on how your assets are set up you might need to offset the assets by a little bit if so that's actually pretty easy to do like for example here this knee attachment let's say i want to use this as a mask if i simply drag it over here onto the head bone and if i do you can see it's not positioned correctly it's in there in this case you can either spawn it on top of the bone and then move it to where you want it or you can just make an empty game object make this one a child of it apply the offset to that child object and keep the parent exactly on zero zero on top of the bone then you would make this one into a prefab instead of that one and spawn this one instead of that one so if your assets come from different packs and they don't match up perfectly then you can use this simple trick just using a parent game object in order to position them exactly what you want and since this method is based on adding parts as children to some bones you might want to place them relative to some bone and not directly on top of the bone that is why on this character this one already comes with a bunch of attachment points but for example the one down here does not so if you've got a skeleton like this one and you want to create some attach points it's very simple it's literally just creating an empty game object then you position it wherever you want it so let's say over there for a face mask as you can see it's a child of the neck so it moves along with it and then you can just position that attach point to get it exactly as you want it so that's how you can use this method with any mesh in any skeleton okay so as you can see the mesh render method is super simple and works on anything you just find the bone or the attach point and just make the object the child of it that's it super simple so in order to make some kind of system using this method you would basically just prepare all of the various helmet prefabs get a reference for the neck or head bone or the helmet attachment point and just pretty much instantiate those acid parts it's really that simple however again going back when doing some customization with skin mesh renders actually quite a bit tricking and the reason for that is because skin mesh renders have one very sneaky thing that must be correctly set otherwise it won't work a while ago i suggest that you keep the mesh object as is so basically with all of the skin mesh renders for all the parts then when handling customization you just enable or disable the ones that you want and in the end you destroy the disabled ones however as soon as i said that you might have thought that you can just make some of these objects as prefabs and then instantiate them just like you would regular mesh renders so for example over here this helmet with a skin mesh render let's duplicate this get rid of the original one so still has a visual now let's drag this into the project to make a prefab and so far it sound works but now let's delete it from here and play the game and now let's say we had some code that would simply instantiate this prefab there you go drop it and right away you see the issue nope there is no visual now if you know about skin mesh renders you might assume that the issue is that the root bone over here is no longer signed so we can just go ahead and find the exact same bone that this one is using so this one is using the spine three so let's drag this reference and as soon as i drag the reference and nope still no visual so this is the really tricky thing about skin mesh renders it caused me quite a lot of frustration to figure this out if you look over here at the prefab and the non-prefab objects if i enable the non-prefab this one does have the vision correctly however the prefab does not have any visual but if we look in the inspector and go between both them you can see everything is exactly the same even if we go into the debug inspector which lets us see a bunch more things and we sign on through both of them we can see both of them are exactly the same total difference is over here the phone but everything else is exactly the same every single field matched up perfectly so what exactly is going on here well the answer is there's one very important feel to a skin mesh render that does not show up on either the regular inspector or the debug inspector and that field is this one the skin mesh render dot bones the skin mesh render must have this ceiling set and it cannot be set in the inspector in any way also it needs to be set in an extremely specific way otherwise again it won't work so here i have a simple script to assign the bones it has a reference to the skin mesh render prefab then also has a reference to the base skin mesh renderer this is the original one on the character and finally it also has a reference to the root bone then over here it instantiates the prefab as a child of this object then sets the bones array with the same ones as the original ones assigns the root bone and then down here also prints out all the transform bones and all the bone lists over here in the editor i drag all the references so first of all the pre-file over there then i've got the original one placed on the object and then finally the actual bone so with all this setup if i run the game and yep it does work there is a character with the spawn helmet spawned from a prefab i can take this clone enable and disable it and yep it does work and down here on the console we can see that list of bones also note how this is not the list of every single bone so for example there's nothing over here on the legs and also the order in this list is also extremely important if i change the original skin mesh render and i choose a different one so just drag it and nope the visual is no longer anywhere to be seen so this is the really tricky thing with skin mesh renders if you use this method then you must use the exact same root bone and also the exact same bone array where you grabbed it from if you don't if you use a different bone array or just organize differently if it's not the exact same one if you don't then the visual will either be invisible or it won't be positioned correctly also one big difference between the skin mesh render and the mesh render is that the skin mesh won't deform along with the bones whereas the mesh render will not whether this is a problem or not really depends on the kind of animations you're using if your game involves lots of squash and stretch animations then it might look odd with just the mesh render method so in that case you really do need to use the skin mesh render method however if your game just has regular animations without any excessive squash and stretch then both methods won't look the same and finally if your asset pack only comes with skin mesh renders for the parts but you want to use the mesh render method you can easily create them you can just drag the part that you want and you get just a single part however note how these ones using the skin mesh when they have a certain offset to the mesh so again you can use the same method that we used a while ago so just create an empty game object make this one a child and then just position this wherever you want so you have just like this and now you have a single part that you can use anywhere you want all right so that was quite a bit more complex than i actually thought it would be there's quite a lot of tiny things depending on how your ads are set up i tried to cover all of the possible ways to do this kind of thing so regardless of how your own assets are set up hopefully this video helped you if you want to add this kind of system onto your game then the best way is really to use an asset pack that has been properly set up so again i highly recommend the cinti modular character pack which is currently on sale it's pretty cheap and with this one alone you can build an infinite amount of characters the sale line soon so if you're interested definitely get it quickly with the film link in the description alright hope that's useful check out these videos to learn some more thanks to these awesome patreon supporters for making these videos possible thank you for watching and i'll see you next time [Music]
Info
Channel: Code Monkey
Views: 113,719
Rating: undefined out of 5
Keywords: how to character customization, unity character customization tutorial, character customization, unity character customization, unity character system, unity swap character, code monkey, unity tutorial, unity game tutorial, unity tutorial for beginners, unity 3d, unity, game design, game development, game dev, game development unity, unity 3d tutorial, programming, coding, c#, code, software development, learn to code, learn programming, unity tutorials, how to make a game
Id: nSmEirb8JGM
Channel Id: undefined
Length: 17min 1sec (1021 seconds)
Published: Mon Apr 25 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.