Difference between revisions of "Custom Spices"

From HoF2 Community Modding Wiki
Jump to: navigation, search
 
Line 2: Line 2:
  
 
The steps below assume that you are comfortable using the [[Unity|Unity editor]] and already have an existing (3D model) and appropriate textures/maps generated for/from it. Examples in the form of a [[Factions|Briarfolk]] spice can be found [http://hof2modwiki.cheesetalks.net/examples/briarfolk_spice_files.zip here].
 
The steps below assume that you are comfortable using the [[Unity|Unity editor]] and already have an existing (3D model) and appropriate textures/maps generated for/from it. Examples in the form of a [[Factions|Briarfolk]] spice can be found [http://hof2modwiki.cheesetalks.net/examples/briarfolk_spice_files.zip here].
 +
[[File:Briarfolk_spice_in-game.png|400px|thumb|left|The example Briarfolk spice as seen in-game]]
 +
<br clear=all>
  
 
==Step 1: Add files to your project==
 
==Step 1: Add files to your project==

Latest revision as of 00:15, 12 February 2019

This tutorial covers how to add your own custom Spices to Hand of Fate 2.

The steps below assume that you are comfortable using the Unity editor and already have an existing (3D model) and appropriate textures/maps generated for/from it. Examples in the form of a Briarfolk spice can be found here.

The example Briarfolk spice as seen in-game


Step 1: Add files to your project

Hand of Fate 2 spices require at least five source files, a mesh and four texture maps tailored to that mesh. Additionally, a shader can be used to match the rendering style of spices already in the game.

3D mesh
The geometry of your spice in a format that Unity can handle, such as a .fbx file, with appropriate UV mapping for the texture maps below.
Albedo texture map
A texture that affects the colour and intensity of light reflected off the spice model.
Metallic texture map
A texture that defines how "metallic" the spice model is.
Normal texture map
A texture that adds extra detail to the spice model.
Occlusion texture map
A texture that affects the indirect lighting that the spice model receives.
Standard_Meeple.shader
A Unity shader that HoF2's meeple materials are based on

Create or locate these files and add them to your project.

  1. The files must be placed somewhere under the Assets folder in your extracted HoF2 SDK folder, but how you choose to organise them is up to you.


Step 2: Add a material

Material settings in the Unity inspector
Remapping materials in an importer mesh

Due to the way that texture maps are applied, each spice uses its own material, which can be created and assigned via the following steps.

  1. Start by creating a new material in the Unity Project Browser (right click, Create->Material).
  2. With the new material selected, select HoF/Character/Meeple from the Shader dropdown in the Inspector panel. This will only appear if Standard_Meeple.shader is present in the project folder.
  3. For the Albedo, Metallic, Normal Map, and Occlusion texture fields, select the corresponding texture maps. Be sure to click the Fix Now button if you see the "This texture is not marked as a normal map" warning.
  4. Set Xaris Fade to 0.132 and Rim power to 6.4. The Inner Colour field can be set to 2D2A2AFF (dark red-grey), and the Outer Colour field FF0000FF (red).
  5. If your mesh does not include embedded textures, select the 3D mesh in the Unity Project Browser and tick the Import Materials checkbox. Under Remapped Materials, select the new material you have created, and then click the Apply button.


Step 3: Create the spice model prefab

Adding components to a prefab in the Unity inspector

Next, a prefab that the game can identify as a spice model needs to be created.

  1. Create a new empty prefab in the Unity Project Browser (right click, Create->Prefab).
  2. Drag and drop the 3D mesh onto the newly created prefab (the icon for the prefab should change to a preview of the model)
  3. Using the Add Component button, add the Model, Model Collision, and Spice Model scripts to the prefab


Step 4: Create the spice

A new spice in the Spices tab with no Model set.

Finally, we have what we need in order to create the spice itself.

  1. Open up the HoF2 editor tools from the Start Window and select the Spices Tab.
  2. Create a new spice by typing its name in the top left text field and clicking the New button.
  3. Select the newly created spice in the editor tools, then drag and drop the spice model prefab from step 3 into the Model field.


Step 5: Other bits and pieces

  • You may need to add AssetBundle Labels to your material, mesh, and textures. The spice model prefab should have automatically had one assigned.
  • Other spice settings and spice model components can be added for additional behaviours if needed.
  • The metallic texture map may need its Texture Type changed to Normal Map in order to match the look and feel of other NPC spices in the game.