Creating a weapon mod U8

From Nexus Mods Wiki
Revision as of 12:46, 12 June 2020 by Pickysaurus (talk | contribs) (Step 1: Model & Texture Import)
Jump to: navigation, search

Before starting this guide, you need to set up the Blade & Sorcery SDK and start a new project. Original Guide by LeoVanceMusic

Step 1: Model & Texture Import

  1. Find a 3D model somewhere on the internet, Sketchfab & Turbosquid are two sites you can download free 3D models from. Your going to want to look for either OBJ or FBX format I don’t know what other formats work in Unity :P (Extract the file if needed)
  2. Create a folder somewhere in your project in the bottom left and drag your downloaded weapon and the texture files into Unity.
  3. Create a material by right-clicking the folder click Create and then click Material
  4. When that is done click on the model file and look at the top right and click on the materials tab. There is 1 option here click on the dropdown menu and click Use Embedded Materials. Now you can drag the material you just created onto the none sections next to each name (if you have more than one section then redo 3 above as many times as you need to until you have enough materials to fill each section with its own Material). Once this is done click apply
  5. *OPTIONAL STEP* Unity has a compression on the textures on import which will make any textures above 2K compressed to 2K. To fix this highlight all the texture files by holding the CTRL button on your keyboard and clicking each one. Once you have them all selected go to the inspector window again and you will see Max Size and Compression change these settings to the desired and click apply.
    • If you have a normal map you will need to mark it as one by clicking just the normal map now and in the Inspector window to the right you will see Texture Type click the dropdown menu and click Normal Map
  6. Click on your material file and drag the corresponding textures to the boxes in the inspector window to the right normal to normal metallic to metallic etc. If you have multiple materials repeat this step until your model looks the way it does on sketchfab. You can check this but clicking the model and looking at the bottom right corner of Unity you can rotate the model by holding right-click on the window and dragging.

If you have followed all the steps correctly you will have a fully textured model ready to go :D

Step 2: Weapon Creation

  1. Drag the model from the folder at the bottom to the Hierarchy window on the left and right-click the file in the Hierarchy window and click Unpack Prefab Completely.
    • Right-click somewhere on the Hierarchy window and click Create Empty. Name it whatever you are going to name the sword for me I used Kingdom Key.
    • Drag your model onto the new object you just created.
  1. Click on your Game Object and on the Inspector window to the right click Add Component type item definition and it should show up click that and it will add the Item definition script and some more game objects that are Important.
    • With Holderpoint, make sure that the blue arrow points to either the blade and or the handle end. The blue arrow points to the floor and determines how the weapon is held when on the body or on a rack. If you can’t see the arrows move, click on the “Global” button at the top, it should change to “Local” which means you can see which direction it goes in. To rotate it, click on this symbol at the top: File:Image3.jpg
    • ParryPoint only matters when you want to make the NPC hold the weapon. I recommend putting it on the middle of your weapon
    • The preview tells the game what the weapon looks like in the book. The blue arrow on the preview is your view in the book. This means that the weapon arrow should point away from the weapon. Scale of the preview should depend on.
  1. Now, add an empty called “Whoosh”. Then, add the component “Whoosh” and move it to the area of the weapon that you want to make the sound when you swing it.
  1. Then, add an empty called “Parry”. Assign the “Parry” definition and fit it to extend the height of your weapon.
  1. Add an empty called “FlyRef” and similarly, the blue arrow points in the direction of which the weapon goes when you throw it with telekinesis or with your hands. Recommended the blue arrow points in the direction of the stabbing area. Move this component to the item definition under the “FlyRef” area.
  1. Next up is the Handle. Create an empty like usual and call it Handle and position it on the handle of your weapon. I will go over the stuff that I know about so far
    • Axis Length - If you want your hand to be able to slide along the handle then you will want to set this over zero until both orbs fill the length of the handle
    • Touch Radius - I always set this to 0.03 I was told once to do it and it worked so now I’m telling you to do it lol.
    • Default Grab Axis Ratio - set this to 0.5 it's realistic enough!
    • Reach - Helps with defining how long the weapon is. Make this just reach the tip of the blade
  1. Now you’re going to want to do the orientations for the weapons which are different now in U8. Click Handle and right click and create an empty repeat this three more times now you should have 4 empties don’t worry about renaming for now.
    • Highlight the first 2 empties and in the Inspector window click Add Component and type handle orientation and click the script to add it.
    • there is a side drop-down menu click it and select right. This will rename them both to OrientRight. Right-click on one of them and add a 1 to the end of the name.
    • Repeat the steps for the last 2 empties, easy to spot cause they haven't been renamed yet ;) this time make sure they are set to left.
    • Highlight both OrientRight1 and OrientLeft1 then select the rotation tool and turn them around 180 degrees alt way of doing this by going to the transform settings and setting one to 180 (this makes it so you can hold the sword upside down too)
    • Click Handle and in the Inspector window click Update to new orientations
    • Highlight you weapon parent the one with the Item Definition on it and drag Handle to Main Handle Left and Main Handle Right
  1. Now comes the colliders. There are 4 different types of colliders. Box colliders, sphere colliders, capsule colliders and mesh colliders. Fit these colliders to the weapon. Then, assign physics materials, such as Blade to the blade of the sword, and “Metal” to the handle. Remember, “Wood” is pierceable, while “WoodHard” cannot. That is the only difference. Each collider MUST be in their own Empty.
  1. Now that you have done this, create an empty called whatever you want, however, I recommend you call it something like “Blunt” and “Blade”. Then, drag the colliders that fit to the empty, such as the blade colliders to the “Blade” empty and the handle colliders to the “Blunt” empty. Then, add “Collider Group” component to the empties.
    • Imbue Effect Renderer - Leave this as none it will use your colliders to do the imbue effect renderer this will give the best effect trust me ;) You must have two colliders on the blade in the collider group
    • Imbue Emission Renderer - this you will have to drag the model that you want to have light up into the none section.

You will need to add emission to this model's material file. You can do that by clicking on the model you dragged and clicking the box that says emission. You need to add a texture here (if your model did not come with any emission textures that’s fine I will write a short tut below on how to create a quick but cool one!!!) click on HDR and set each colour to 1 (this will make your emission texture invisible until you imbue it).

  1. Now, create damagers. For a usual sword, you need a pierce, slash and blunt damaged. File:Image1.jpg
    • Slash fits the size of the weapon. The “Depth” should be something very small, like 0.003, as it can’t be 0.
    • For "pierce", the length must be 0 and direction should be “Forward”. Then, the axis should be at the tip of the pierceable bit.File:Image2.jpg
    • The pierce must also fit the blade, depending on how far you want to stab
    • With blunt, set length and depth to 0.
  1. Now, with the damagers, assign the collider group to it. For example, blunt damager should have the “Handle” collider group set to it as it will deal blunt damage. For blunt weapons, you must create 2 collider groups, one for the head and one for the handle, just to make it so the handle does not deal the same damager as the head. Don’t worry about Collider Only that's if you wanted to have a damager setup to a specific collider.

Step 3: Weapon Export

  1. Now, your weapon should be complete. Drag the main parent, which should be the name of your weapon, to the folder you have created at the bottom of the program.
  2. Click on the prefab, a box should appear in the bottom right-hand corner. Click on the AssetBundles, click “New” then click out of it and click on the AssetBundles, add new and then assign a name to it.
  3. Now, create a folder in StreamingAssets, add a manifest file, which you can copy and edit via a program like “NotePad++”.
  4. Now, locate the Blade and Sorcery tab at the top, click on “Mod Configuration” (you can edit the Manifest file here too). Then, locate the folder, click “New Weapon” and edit all the components inside. Make sure the ID is unique, and make sure Pierce is at the top, slash is in the middle and blunt is at the bottom, which can be configured in the list. This should create the JSON for you in the folder.
  5. (if your Mod Configuration is broken and does not work, copy a JSON from the Default>Items folder that suits the weapon, Item_Weapon_SwordShortCommon maybe, copy it, paste it into your mod folder, open it and edit all the necessary components like the item ID, Damagers etc. Make sure you change the name of the file, too)
  6. If you want imbue effects like the fireball shoot and gravity smash you will need to copy and paste ColliderGroup_BladeT4 from Default>ColliderGroups into your mod folder. Change the name to whatever you want. Open the file and change the Id and change “imbueType” from 2 to 3 then copy the id and paste and replace BladeT2 under colliderGroups
  7. Now, locate the Blade and Sorcery tab at the top again, and click on “Asset Bundle Builder”, find your AssetBundle name, click on the dropdown to select the mod folder. Tick the “Extract to folder” option, and click “Extract”. Now, your weapon is complete :)

Emission Texture Tutorial

This will be a short one because it's honestly not too hard :P

  1. Open up photoshop or use the online photoshop (It’s free)
  2. Make a new file
  3. Set width & Height to 4096 (this will make sure it looks good)
  4. Set background to black
  5. Add desired textures setting each one to while on a new layer you can find scratch textures on google or just use this pack I brewed up :P
  6. Set every texture layer to Linear Dodge (Add) except the background layer
  7. Save and you're done :D

Video Tutorial

This is an alternate video tutorial by ButtersAndSorcery.