Tactics RPG Series Intro

I’ve decided to start a new section of my blog where I create working game samples and then blog about them. I have been working on a Tactics RPG game for awhile now and you can see the results so far in this sample video:

or download the and try out the project yourself.

In this project we will focus on the creation of an RPG game engine. I spent a lot of time looking at various games in the Final Fantasy series for inspiration and then decided to focus on Final Fantasy Tactics (Game Boy Advance). I came to this conclusion because much of the elements in a Tactics game (job-based stat growth, abilities, etc) could also be used in a non-tactics game, but the tactics game adds additional complexity due to the game board (path finding, etc) that wouldn’t have been addressed otherwise.

Prerequisites

This series contains intermediate to advanced level material, therefore I will assume you are familiar with C# and Unity. If you are new to C# I would recommend following along with my own tutorial series here.

I will also make use of code and ideas written in previous posts. I recommend you read over the following:

Resources

At the time of this writing I am using Unity 5.0.0f4 Personal edition (one of my goals is to keep everything completely compatible with the free version). You can download Unity here.

Download and try out the project using this link. Note that development on this project is currently on-going and is VERY likely to be cleaned up and or refactored if not just completely changed over time, particularly as I actually start writing about each part.

It would be beneficial to play the game before following along so you can get a better grasp of all the features we will be adding. Some of the features I have added so far include:

  • Dynamic UI – menus which take advantage of Unity’s new UI tools. This includes UI which displays the selected unit and its stats, a command menu, a coversation panel, etc.
  • Game State Machine – allows the ability to play a complete battle by entering commands to move units, select and confirm actions, etc. Moves can also be undone.
  • 3D non-square battle maps. Battle maps can be randomly generated and or modified by hand. They can take any shape and the height of each tile can be modified as desired. This also affects game play such as by the jump-height restriction on a unit’s movement.
  • Camera system – smoothly follows selected units and cursor movement.
  • Flexible navigation system – Units can have different means of pathfinding and moving around the game board such as by walking, flying or teleporting.
  • Job system – used for leveling up units with a good variety of stats. Theses stats have an affect on gameplay such as the speed at which units get turns, or the amount of damage they inflict or receive from various attacks.
  • Ability system – used for attacking, etc.
  • Animation system – UI animates into and out of the screen, units tween from tile to tile along their movement path, etc.

35 thoughts on “Tactics RPG Series Intro

  1. Hey! Do you have a little bit of free time? If so, I would like to ask you a few questions about this project and Unity, maybe in private or something? Don’t really know how to reach you personnally – you may be busy but I guess it’s worth the try 🙂

    1. Sorry for the slow response – I’m traveling and on vacation this week. I’d be happy to help you resolve the problem, but I’m afraid there is any number of things which could be the issue. Your question is a bit vague, but hopefully this will help.

      1.) If you are trying out the prototype project which I had linked to on this post, make sure you extract the zip file.

      2.) If you are trying to download the actual project from the repository here,
      https://bitbucket.org/jparham/blogtacticsrpg/src
      , then I recommend you use a good source control software like SourceTree, then checkout the development branch.

      Regardless of which project you grabbed, you can open it with Unity 5.0 or greater, then open the “Battle” scene by double clicking the scene file in the project panel. Press “Play” in the editor and you should experience a game very much like the youtube video displayed above.

  2. Hi! This looks like an amazing tutorial. How difficult would it be to apply these concepts to a 2D game?

    I’m trying to create a 2D tactics system and am new to Unity, so I am researching as much as I can. I might just start with a 3D project and follow this tutorial to get the fundamentals down, but I ultimately want to work with 2D games.

    This means instead of creating a 3D game board and objects, I would be using a 2D tiled map and sprite art. I’m not sure if you have any 2D experience with Unity, but any insight would be appreciated!

    Thanks for this tutorial. It’s really exciting.

    1. Thanks, I put a lot of work into it, so I hope you like it.

      If I were creating the game in 2D I would create most of the systems the same way. I would also treat the code for the board the same – as if it were a 3D area (assuming you want height to play a role).

      Really the only difference is how you display it to the user. The 3D route is easier because it doesn’t require you to do anything tricky with layers and zDepths, etc. All of the visual sorting is handled automatically by the camera and the positions of the objects. If you were going for a flat playing ground a lot of those difficulties will no longer be an issue.

      Good luck!

    1. This tutorial is considered “complete” at this moment. You can get full access to the source code here:
      https://bitbucket.org/jparham/blogtacticsrpg

      Once you download the project and open it in Unity, from the file menu choose “Pre Production->Parse Jobs” which will do some preparation needed for the game to run. All of this is also documented along the way, but if you come in at the end you might think it was just broken, so I thought you would want to know.

      1. The game looks wonderful! :D. Though I’m just wondering, can the computer controller (WASD) changed for mobile (Up down left right buttons)? If ever, can you mind helping me convert it to that? I’m studying the game you’ve made and yeah it looks really great!

        1. For this game, input is handled by polling the system every frame. Unity exposed a variety of input options like keboard, mouse and game controllers through the Input class. It also already provides tracking of mobile input which it calls “touches” see the documentation here:
          https://docs.unity3d.com/Manual/MobileInput.html

          You can also make use of Unity’s UI and allow canvas buttons to control your input. This will work with touches on mobile as well as other input mechanisms. It could be as simple as setting up buttons on screen with delegate methods pointing to your input manager script. If a user presses the up button then set a bool on your manager script to track it. Each update loop, look for the first button press that it finds and act upon it (post a notification event like before), then reset all the bools. Note that you may want to do it this way because with touches you could press more than one button at a time during the same frame which can cause your game to get into unexpected states if you aren’t very careful with your programming. For example, if you have two menu buttons and you choose both, do you navigate to the first menu screen, the second menu screen, or both?

  3. Hi sir jon! I’m currently studying the one you placed on the repository, but can you please tell me where exactly should I place the animation of the “Attack” and the “Skill” animations? I’m tried to place it on the “Ability” script, but everytime 1 character attacks, everyone else attacks on the same time. Oh and btw i’m using boolean as parameters. I’m already able to place the walk anim on the Walk movement.Though now i’m having a hard time where to put the animation of attack. Can you please guide me? Thanks to your project, i’ve learned a lot. More power to you, sir!

    1. Hello 🙂
      There are a lot of options for this. It sounds like you are using Mecanim, which is a pretty powerful feature that should be able to handle it just fine. I would probably add some sort of animation data component to each skill prefab, which you could then “activate” at a new GameState (just like we have a state to animate the traversal of a path, you could insert a state to animate the use of a skill). This component would hold whatever kinds of settings you would want in order to make it easy to update the animator of the current unit. Mecanim has the ability to add triggers, so you could easily respond to the frames an attack actually hits (and play an appropriate animation on the target unit as well) as well as for changing states so that when they are done with the skill you can inform the game state machine to proceed.

      1. Hi sir! Thanks for the answer, but can you pinpoint where exactly or in which script should i place the codes for the ‘Attack’ animation? Thank you once again and have a good day ahead!

        1. Unfortunately, no, because you haven’t created them yet 🙂

          Ideally each class has a single responsibility and I haven’t created a class to handle character animation, nor have I created an appropriate state to handle it.

          One of the reasons I didn’t do this is because I didn’t have any resources to work with, but also because there are so many different ways people might want to work with the animation and polish etc, that my hope was you would understand the foundation I laid well enough to build up from there.

  4. Hi. thanks for the great tutorial. May I ask you something?

    Can I make game as a hobby? I tried to make one half of my life, and since I am 4th grade in college next year I’m running out of time for everything. I really wanted to be a game developer but I came to realize I have done nothing yet. Never made a game, always ended up with quarter-finished abominations, and not qualified to any jobs. My family and nearby persons all want me to get a stable job, so I need to start prepare for job interviews or get some technical licenses.

    So the thing is: I want to make game, was a dream for all these years, but reality pushes me to prepare for other things so I can go in some company and get a job. I’m being torn apart. I know I can get enough money to live if I choose my dream.

    It would be a salvation if I can chase the years-long dream in my spare time. Can I do this?

    1. Short Answer: Yes! You can do this!

      Long Answer:

      I was blessed to be raised by parents who instilled in me the idea that I could do anything I wanted – as long as I was willing to put forth the effort required. I believe the same thing for others while acknowledging that the amount of work needed varies depending on your personal circumstance.

      The honest truth about game development is that it is a highly competitive field because this dream is shared by many others, myself included. This may mean you will face many more failures and difficulties in this pursuit than you would for other goals. It does not mean that you should abandon it though. If it means so much to you then just take a step back to realize what you want to accomplish and plan accordingly – it doesn’t have to be realized before you graduate, life-long hobbies can be very rewarding too 🙂

      I have made several games as a hobby, it is totally possible, but also requires a lot of time and discipline. The games I have actually completed were “small” – think of Tetris instead of Final Fantasy or World of Warcraft. Don’t imagine that you are giving up your dream game by making simple ones, because it is just the opposite. Making little games gives you very valuable experience AND if you take your time with them then you often end up with a collection of reusable scripts that you can use on your next game. Furthermore you are building confidence by actually completing mini-goals. Take one step at a time and over a period of years you may find that you can make just about anything.

  5. Hi Jon,

    Thanks for putting these tutorials together! I’m just going through the beginning tutorials and am interested in using this one to learn from. When I try to open the project in Unity, I get some errors along the way. If you don’t mind taking the time to look over them, it’d be greatly appreciated.

    I get the following error when I first try to open the project.

    “Your project was last opened with a different setup of Unity.

    The saved project (5.3.1f1) does not match the launched editor (5.5.0f3).

    This may require re-import. Please be aware that opening in an older version is unsupported.

    Note that if a build target installation is missing, this may also cause a re-import.”

    Then when it does open, I have the following errors in the console.

    – Rebuilding Library because the asset database could not be found!

    – Assets/Scripts/Controller/Battle States/EndBattleState.cs(9,15): warning CS0618: `UnityEngine.Application.LoadLevel(int)’ is obsolete: `Use SceneManager.LoadScene’

    – Failed to create device file:
    2 The system cannot find the file specified.

    Do you have any suggestions and will I still be able to use your tutorial even if I can’t get this to work?

    Thanks again!

    1. Hey Jacob,

      The project should still work in 5.5+. Re-importing the assets and rebuilding the library is nothing to worry about. The “LoadLevel” stuff is deprecated but still compiles. If you want to update it then check out the documentation here:
      https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.LoadScene.html

      Basically just add another import statement at the top of your script:
      using UnityEngine.SceneManagement;

      And then replace the LoadLevel line with the following:
      SceneManager.LoadScene (0, LoadSceneMode.Single);

  6. Hey Jon,

    I just downloaded the project and have been playing around with it a bit, and something interesting happened. The game threw a null reference exception after I tried casting fire at some point. I realized this is because my unit actually killed himself by casting the spell on his own square. I know that units are not expected to kill themselves normally, but I wonder how you could get around this, since the game cannot continue after this happens (the cursor just sits at the place formerly occupied by the unit, probably expecting the unit to move or wait).

    1. Great observation. Since you know what was causing the problem, you can get around it by adding extra logic to the current battle state. In the event that the current combatant is KO’d you will need some logic to change combatants and states accordingly. It could be that the unintentional KO also resulted in a loss of the entire match, and not just switching to a new turn.

  7. Hi Jon! Thanks for your tutorial. I am highly interested in making a Final Fantasy Tactics/Ogre Tactics -like game. Can we use your project as a baseline for our intended game? — https://bitbucket.org/jparham/blogtacticsrpg

    We are highly interested in developing games for social change and we believe that we can create a tactical RPG that would help promote heroism – no matter how small a social change and impact we can make on society. We would be sure to credit you for your source code. Thanks! 😀

    1. Hi, best of luck to you on making your own game, its a fun (but long) journey! You are very welcome to use my code on the tactics project – it is all available under the MIT license (you can see a link to this license at the top of my site). I would also love to see whatever you end up creating.

      1. Thanks Jon! I’ll be reviewing that MIT license and make sure that I don’t infringe on your rights. I really appreciate the work you have invested in this project. More power to you and your tutorials. You’re a big help to budding game developers like me. 😀

  8. Great job man. Please continue posting new things about turn based RPG until finish a full game system. You will give the people more hope to start create this wonderful type of game. Keep going. I’m waiting more.

    1. Glad you enjoyed it. For now, I would recommend following along with the Unofficial Pokemon Board Game project that I am currently finishing up. While the Tactics RPG project was great for a deep dive on the complexities of a battle engine, the UPBG project is great for broad coverage of an entire game (albeit a simpler one). If you can fully understand both projects then you should be very well prepared to make your own fully fleshed out Tactics RPG.

      I did really enjoy working on the TRPG though, and who knows, I may revisit it in the future. With enough patrons I may even have a budget to put in nice looking content to work with.

Leave a Reply

Your email address will not be published. Required fields are marked *