-
-
Notifications
You must be signed in to change notification settings - Fork 304
Adding custom characters (v1.7)
Written by @CubbyCrazes
- https://www.youtube.com/watch?v=nIoXOplUvAw
- Once done making/importing the mesh, go to object mode. Your skeleton should be the one from
mario_big_source.blend
, copied over. Make sure all Mario's animations are in it. - Make sure you aren't selecting anything, then hold control and select the skeleton then the mesh, in that order. Holding control lets you select them both.
- Press
Ctrl+P
, then set the parent of the mesh to "Armature deform". - Weight paint the mesh to the skeleton. Be careful to not forget any single vertices.
- Go to the materials menu on your model, and add materials. It's very recommended for you to have at least two seperate materials for the clothes and the face. You can have as many as you want, but the process will get more tasking in Unity the more you have on the model.
- Name your material, then set its shader to "Diffuse BSDF". This is one of the simplest shaders, as all it does is just take a single input. The roughness doesn't matter, so for simplicity you can just set it to 1. Don't touch the "Normal".
- Click on the small circle on the bar of the shader's "Color" input bar. This lets you select what kind of input you want it to have. Under the texture list, select "Image texture".
- Open the image you want to use as the texture. The DS only had nearest neighbor interpolation. It's not required, but recommended simply so you can see the precision while applying textures.
- Select the faces on the model you want to apply certain textures to. For example, if you have a "Hat" material, select all the faces on the hat part of the model. Next, under the name bar in the materials menu, hit "Assign". This puts the texture on the model as you could probably guess.
- While you still have all the faces of the part you wanna apply selected, click on "UV" at the top and hit "Unwrap". Next, go to the UV Editing tab on the very top of Blender.
- From here, you can stretch and edit the selection to line up the texture on your model. This is where the precision of nearest neighbor interpolation really helps.
- Repeat from substep 5 until your model is completely covered. If you have materials with more than one part of the texture, such as a material for both the hat and head, do the same steps with the single material but with different selections.
- Go to object mode and click your model. Right click, and hit "Shade smooth". This makes it not look blocky.
- Repeat steps 1 and 2 again for the small model, if your mod has those.
You're done, you can now export your model. FBX is format you should export it in. Now, it's time to go to Unity.
- Go to the "Models" folder, then go to "Players". Make a new folder for your character, then go into it and drag your model(s) into it.
- Add all of your texture images to the folder. It is VERY recommended to have the textures for the face and the clothes be separate. They use different split-ups.
- Make sure all of your textures' types are set to "Default". Set the shape to "2D array". Columns should be set to 1 for now. The default value for rows is 12, because there's four powerup states that modify textures: Normal, Fire Flower, Propeller, andIce Flower. The number of rows must be a multiple of 3. You'll see why below.
- Open your clothes texture in an image editing program like Aseprite (What I use). Multiply the image's height by the number of rows you put in for the texture, and have the already existing texture be at the very top. Add copies of the clothes texture at every interval of its height. The next two are masks for the custom colors. The second one would be the equivalent of Mario's overall colors, and the third would be the equivalent of his shirt. So, in the order for the texture copy, it goes like this: Normal texture, overalls mask, shirt/hat mask.
- Add copies of your clothes texture and its masks at every 3rd height interval in the image; For example, if your original texture is 64 pixels tall, you'd add the masks at Y positions 64 and 128, while the original is at 0. The copies would be at intervals of 192 pixels, because 192 is 3 * 64. These copies are for the different powerups. The copies for powerups go in this order: Normal, fire, propeller, ice. If you want the secondary clothes change to the color of the primary clothes, like Mario's overalls changing to red while he has fire flower, move the shirt mask to replce the overalls mask and get rid of the overalls mask entirely. Make sure this is done only on the copies with powerups where you want that to happen.
- Open your face texture in your image editor and make 4 copies of it, stacking them each in rows. The 3 copies below the first are different facial variants. No masks are needed for this. The facial variants go in this order: Normal, half blink, full blink, death.
- Going back to Unity, you can set the textures' clamp mode to whatever you want. If you did your UV mapping right, it won't matter. But if it does, you can try different options and see what looks best. It's recommended to set the filter mode to "Point (no filter)". This is the same as nearest neighbor interpolation, and it's the only one DS had support for. It's not required, but if you want the DS look, that's the one to choose. In the box for the platform-specific settings (The one that says "Default" at the top, below the interpolation settings), change the compression to none. Hit apply, and repeat this substep for all the textures.
- Go to the Materials folder, then go into the 3d folder. Make a new folder for your character. Copy all of Mario's default materials into your new folder, as it will make this process very much easier. Rename them to fit your character, then change the input texture to be your character's equivalent for Mario's texture. Make sure the clothes and face textures go in their image spots respectively. If you have more textures than Mario does, copy the clothes materal and put in the texture you need, but if it's a texture that doesn't need to change its color for the powerups, uncheck the box that says "MultiPowerupMaterial" and save.
-
Go to the Sprites folder in the main Assets folder. Go to UI, then open
ui.png
in your image editor. Add your character's UI sprite somewhere on the sheet, resizing it with the pivot being in the bottom left if you need to. It is very recommended for their sprite to be 20x20, but it's not required. Save, and go back to Unity. -
Edit
ui.png
inside Unity to add your character's sprite to the list of sprites contained in that image. Give it a name and border, having the pivot for the sprite be in the middle. -
Go to the Resources folder in the main Assets folder. Then go to the Fonts folder. Find the
UISymbols
font and edit it. Open the "Sprite Glyph Table". Go all the way to the end, and click the last entry in the table. Click on the plus button that shows up below it when you click it. That adds a copy of that glyph you can edit. Input the X, Y, width and height for your sprite using the values generated by you adding the sprite to the list of sprites inui.png
. For the Glyph Metrics, input as follows.W: 20. H: 20. BX: -2. BY: 20. AD: 28
. These should be copies of the same Glyph Metrics on Mario and Luigi's UI sprites. Leave the scale at 1 and the atlas index at 0. Take note of the glyph's ID in the table, it's important for the next substep. -
Close the Sprite Glyph Table, and open the Sprite Character Table. Go to the last page on the table, and click on the last item. Click the plus below it. In the new item, leave the Unicode at
FFFE
. I don't think the name matters, but I put in the correct name for the sprite anyway just in case, it should be the same one you named the sprite inui.png
. Put in the ID of the glyph you just made and leave scale at 1, and then save. It's okay for the character table index and the glyph ID to not be the same. -
Next, go back to the sprites folder and then go to the UI folder again. Open
loading-sprites.png
in your image editor to add the loading screen sprites for your character. Resize the image to however big you need it to be, using the bottom left as the pivot. Add your sprites in the new bounds of the image, save, then go back to Unity. -
In Unity, edit
loading-sprites.png
so you can add new sprites to the list of sprites contained in it. The sprites you added MUST be the same size as Mario and Luigi's sprites. If you need bigger sprites, you need to edit the image to change all of the character sprites to be the same size. If you plan on adding a lot of characters, as well as some that could possibly be really big, it's highly recommended for you to make them bigger. -
Go back to the
Resources
folder inside the main Assets folder. Then, go to theSound
folder. Next, the character folder. Copy Mario's sound folder and rename it to the name of your character. I recommend using the same syntax as the other sound folders, that being your character's name in all lowercase. -
Go into the new sound folder, and gather all the voice lines you will need to replace all of Mario's sounds in the new folder. They don't need to be in the same sound format, but it is recommended. Replace all of his sounds with your character's sounds.
-
Go to the Resources folder outside in the main Assets folder. Go to the
Scriptables
folder, then go to Characters. Copy Mario'sPlayerData
script and rename it to fit your character. Rename and reselect the values inside the newPlayerData
:Sound Folder: The name of the sound folder you just made. Prefab: "Player" and your character's name with capitals. Uistring: "<sprite=x>". Replace x with the name of the index of your character's sprite in the Sprite Character Table you added onto earlier. Loading Small Sprite: The sprite of your character in the small state added in loading-sprites.png Loading Big Sprite: The sprite of your character in the big/super state added in loading-sprites.png Ready Sprite: The UI sprite of your character added in ui.png Small Overrides: Keep these as SmallMario or SmallLuigi, depending on if you want your character to animate like Mario/Luigi. If you want your character to have custom animations, go bother MiiBumm. Large Overrides: Same as above, but with LargeMario and LargeLuigi.
- Go to the
Resources
folder again. Go to thePrefabs
folder. Take thePlayerMario
(NOTPlayerLuigi
, this breaks it) prefab and copy it, renaming it to the same name you put it for the "Prefab" string in the character'sPlayerData
. - Open the prefab in prefab edit mode. Click on Mario's mesh, and replace it with the mesh inside the model file you imported (what feels like 27 years ago). The mesh's name would be the same name you put in for it in Blender.
- Under the Materials list in the prefab menu on the side, put in all of your character's materials, and change the order of them around until they all line up properly. If your mod has character outlines, make sure the very creatively named ouline material "
OutlineMaterial
" is the last on the list, as its ID in the material list is always -1. - Resize the character's mesh to match their actual size compared to Mario. Also resize their blue shell mesh, as well as activating the propeller hat mesh on the model and resizing it to fit, then deactivating it again. Save, then exit prefab mode. If your mod has small models, repeat this process from substep 2 with the small character's mesh.
- Going back to the Prefabs folder, go into the Static folder. Click on the
GlobalController
prefab. Open the list inside it named Characters, and add your character'sPlayerData
at the end of the list. - Go back to the
Resources
folder. Go intoScriptables
, and thenPlayerColors
. Edit all of thePlayerColors
scripts by adding an index in their arrays with your character'sPlayerData
and the colors you want them to have. If you edited the script to have names, you can include that character's colors' names as well. Save, then open the "MainMenu" scene. - In the "MainMenu" scene, navigate the hierarchy. Go deeper in to find the exact thing you need:
Canvas -> StoneBG -> CurrentLobby -> SettingsPanel -> Viewport -> Content -> LblCharacter -> CharacterDropdown
. Click on "CharacterDropdown" to open its prefab settings and scroll down to find its "Options" list, containing all the names of the characters. Add an item to that list and put in your character's name, as well as their character icons if you have those included. Those would be their sprites from ui.png. These names HAVE to line up with the characters' indexes on the Characters list in theGlobalController
prefab, otherwise your characters' names and indexes will be desynced. If all is done correctly, your character should now be properly implemented into MvL.