Tactics RPG Project Setup

In this project we will create and configure a new project to hold our Tactics RPG game engine. We will add folders for organization, import some existing assets, and create a few more assets which we will begin implementing in future lessons.

Project Creation

Open Unity and choose the New Project button from the initial dialog. Alternatively if Unity was already open you can use the menu bar File->New Project…. Provide an appropriate project name and location in the dialog which appears, leave the default mode to 3D, and then click the Create project button to confirm your settings.

Folder Setup

Project organization is very important, and becomes increasingly important as your project grows. Whenever I create a new Unity project, I usually begin by creating a few folders I know I will use in order to help encourage proper habits.

To create a folder you can either right-click inside of the Project pane and choose Create->Folder from the context menu, or use the button just beneath the tab at the top of the project pane.

Start by adding the following folders:

  • Editor
  • Materials
  • Prefabs
  • Resources
  • Scenes
  • Scripts
  • Settings
  • Textures

For the most part you can name your folders and organize your project however you like, but it is worth pointing out that two of these folders, Editor and Resources are special to Unity. Click Here for a more complete list of Unity’s special folders and their purposes.

Tip:

If you accidentally nest the folders when creating them, you can click and drag the folder back out to the root level from within the project pane. While dragging, a thin blue line will indicate moving a folder parallel to another folder and a thick blue line over a folder will indicate you would be making it a sub folder.

Import Assets

It is relatively common to start a project using existing assets or plugins. I have created a few to help get this project started.

02_TacticsRPG_Scripts.zip – This .zip file includes a collection of scripts which I initially created in some older posts (Dynamic Animation Part 1 and Dynamic Animation Part 2) as well as a few extras we will use for our animation needs. I added some folders to my project hierarchy such that these scripts are placed in Scripts/Common/Animation. The Common folder is used to organize scripts which I might use across multiple projects, and then the Animation folder just keeps all of the scripts bundled together.

02_TacticsRPG_Textures.zip – this .zip file contains a few textures we can use for our UI and for the game board tiles. I added a folder inside of Textures called UI and placed all textures there with the exception of Dirt.png which I left in the root of the Textures folder.

Note that you can use Unity’s Asset Packages for exporting and importing assets, and they will maintain things such as folder hierarchy, import settings etc. However, I decided not to use them just in case forward compatibility might be an issue.

Modify Texture Settings

Multi-select all of the UI textures we just imported. Change the Texture Type from Texture to Sprite (2D and UI). This step is required in order to use our textures in Unity’s new UI components such as Image.

Set the Packing Tag to UI. This causes all of the images to be saved to a single texture called a Sprite Atlas for optimization sake. Note that this feature is currently not compatible with textures located in the Resources folder.

Tip:

You can view the atlases which Unity has created to verify that everything is working as you intended. From the menu bar choose Window->Sprite Packer. The atlases are auto created when entering play mode or by creating a build of your project, but you can also trigger their creation by clicking the Pack button in the top left of this window. There should be an atlas for each of the packing tags you have specified, and you can view the corresponding atlas from the View atlas: pull down menu.

Several of these textures will have an Image Type set to Sliced which allows the textures to stretch in specified areas, while keeping the corners unstretched. You can modify the slice locations by selecting a single sprite and then clicking the Sprite Editor button from the inspector pane. In the Sprite Editor dialog which appears, adjust the Border values L, T, R, and B which stand for Left, Top, Right, and Bottom. As you manipulate the values you should see green lines overlay your sprite indicating where the slice will occur. Following is a list of images which need slicing data, and the values used in L,T,R,B order:

  • AbilityMenu {44, 42, 1, 32}
  • ActionNameBacker {8, 0, 8, 0}
  • BlueAttackPanel {3, 0, 47, 0}
  • ConversationPanel {71, 70, 2, 70}
  • RedAttackPanel {3, 0, 47, 0}

Create Materials

In the project pane, select the Materials folder and then from the Create button choose Material. This should create a new material inside of the appropriate folder. Name the material Dirt. There is a round mark to the left of Albedo – tap this mark to open up the Select Texture dialog, and select Dirt. Since Dirt isn’t shiny, set the Metallic Smoothness to 0.

The Dirt material will be used as a placeholder on the board tiles we create. It is a simple brown texture with a darker border to help visually differentiate where tiles are located.

Next we will create two materials which will help identify the hero units vs the enemy units. Name them Ally and Enemy and drop the Metallic Smoothness to 0.25. Give the Ally a green color on Albedo such as RGB {86, 200, 88}. Give the Enemy a red color on Albedo such as RGB {183, 43, 61}.

We will let our units share a material representing their eyes (we will use this to help determine which way our units are facing). So create another material called Eyes.

Finally, we will use one more material on an object which represents which tile is currently selected, as well as for a facing indicator. Create a new material called Selection and give it a yellow color on Albedo such as RGB {255, 255, 0}

Create Objects

First let’s create the board tile. From the menu bar choose GameObject->3D Object->Cube. Name the object Tile and assign the Dirt material to the Mesh Renderer in the inspector (or by drag and drop in the scene view). Now drag and drop the Tile GameObject from the Hierarchy pane onto the Prefabs folder in the Project pane. This creates a prefab of our Tile. Now you can delete the Tile instance from the Scene (by right-clicking the Tile in the Hierarchy pane and choosing Delete). You will be able to recreate new instances (copies) of your Tile prefab at run time.

Next let’s create a generic unit for our heroes. Start by creating an empty GameObject – from the menu bar choose GameObject->Create Empty. Name the object Hero. This root object will be used as a handle to position the unit on the board. Add another empty GameObject as a child (make one object the child of another by dragging it onto the object in the Hierarchy pane), and name it Jumper. This object will be used to animate the vertical arc of a jump when a Unit traverses between non-level ground. Now create a sphere as a child of the Jumper GameObject – From the menu bar choose GameObject->3D Object->Sphere. Change the Scale of the sphere to XYZ {0.8, 0.8, 0.8}. Assign the Ally material to this sphere. Create another sphere as a child of this sphere to represent an eye. Scale the eye to XYZ {0.25, 0.25, 0.25} and set its Position to XYZ {0.17, 0.32, 0.3}. Assign the Eyes material to this sphere. Duplicate the eye (from the menu bar choose Edit->Duplicate) and move the copy to -0.17 on the Position’s X axis.

Duplicate the Hero and rename the copy to Monster. Change the material on the body from Ally to Enemy. Now drag both the Hero and Monster objects to the Prefabs folder one at a time in order to create Prefabs for each. Delete the original instances from the scene when you are done.

The last object we will make will be an object which marks the currently selected board tile. It will look like there are angle brackets at each of the four corners of a square unit. Start by making an empty GameObject named Tile Selection Indicator. Then add a Cube as a child. Assign this cube the Selection material. Remove the Box Collider Component (Right click its title and choose Remove Component). Change the Scale of the cube to XYZ{0.1, 0.1, 0.3}. Now clone the cube until there are 8 total. Use the following transform values for the cubes:

  1. Position{0.5, 0, 0.4}, Rotation{0, 0, 0}
  2. Position{0.4, 0, -0.5}, Rotation{0, 90, 0}
  3. Position{-0.5, 0, -0.4}, Rotation{0, -180, 0}
  4. Position{-0.4, 0, 0.5}, Rotation{0, -90, 0}
  5. Position{0.4, 0, 0.5}, Rotation{0, 90, 0}
  6. Position{0.5, 0, -0.4}, Rotation{0, -180, 0}
  7. Position{-0.4, 0, -0.5}, Rotation{0, -90, 0}
  8. Position{-0.5, 0, 0.4}, Rotation{0, 0, 0}

After modifying assets in your project, you should always save the project itself. From the menu bar choose File->Save Project.

Summary

In this lesson we created our project and got several assets ready for use in the next lessons. We discussed the importance of a well organized project and learned how to create and modify folder hierarchies. We covered how to import existing assets into our project and modify import settings as necessary. We discussed atlases, sprites and sliced sprites for 9-slice stretching in the UI. Finally we created materials and prefabs to represent our game board, units, and a tile selection indicator.

Advertisements

6 thoughts on “Tactics RPG Project Setup

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s