Character Customization

Character Customization

Character Customization was one of the most advanced scripts I worked on during my time working on this project. The character Customization script allows the player to customize their character with various clothing items. The script utilizes a couple of different techniques to allow the clothing to dynamically change, and move along together with the rig of the player.

The first thing we had to do was figure out a way to instantiate the clothing pieces and append them to the rig itself. While this in itself wasn't a problem. The armor pieces wouldn't follow the proper animations of the model. They would follow the root of the player and that was it. After a lot of revisions and changes, we figured out a better way to go about this.

The clothing pieces that we were appending didn't have a rig on their own, which meant we couldn't transfer the animations from the player's rig over to the clothing pieces. We fixed this by using blender's automatic weight paint option. We would import the 3D model into Blender's 3D software, Import the original player rig, place the piece of clothing as best as we could on the player, then we would use the automatic weight paint option to get the player's rig on the clothing as well. 

Now that the piece of clothing had a script, it was time to transfer the original animations. We didn't want the clothing pieces to be exported with an animation, this would cost a lot of time and resources. We decided that we wanted to have the animations copied dynamically from the player inside of Unity. 

Every mesh that had bones on/in them had a skinned mesh renderer attached as well. what we did is we selected the original player mesh, we then copied the bones from that skinned mesh renderer onto the piece of clothing that we were instantiating. Since the clothing were separate mehses we had to loop through the entire prefab and only instantiate the objects that had the skinned mesh renderer on it. 

The only problem that remained afterwards was the clipping. The objects moved, but this would sometimes cause the player to clip through their clothing pieces. We fixed this by adding the option to cull certain parts of the players skinned mesh renderer based on the ID.