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.

63 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?

          1. Looking around for possible solutions, but I am afraid I don`t exactly follow how to make a button for movement. For example if I add a new button to the battle scene, I was hoping to simply hook that up to the horizontal and vertical access to do movement, but I read that you can not change the input values like you can with other variables.

            I have no problem running code from a function with buttons normally, so I assume that I need a functions somewhere in the battle controller? And that function would send out a message that the horizontal or vertical changed with the onmove?

            But I can not quite link the ideas all of the way.

            Can you give me any

          2. For this project, I would recommend looking at lesson 4 “User Input Controller”. In the same way that we poll for keyboard input, you can also poll for button input such as an Selectable.IsPressed. Or depending on the movement you are going for you may only want to observe a Button.onClick event. You could approach this a variety of different ways of course, such as having a separate button script that observes its own button and updates the “User Input Controller” which then sends notifications to the relevant subscribers, or you could have the “User Input Controller” be updated such that it has direct references to buttons that it can observe directly. Does that help?

  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.

  9. Hi, man. I’ve been reading your posts and so far I think this is the best source of the genre. I have thoughts in make a game with a simple concept: the player will have a main window where it can customize their characters (skills, shopping, formation, etc) and then look foward for a battle with the same tactical mechanics that you show here. But I really wanted to make this a multiplayer experience, in 1v1 real-time battles instead of CPU IA.

    So, my main question is: Do you have any experience with the multiplayer aspect of this type of game? Where players can play a battle like we can see in your project by alternating turns. It could be for android or web, but if you have any knowledge on this could you point me directions? I’m already reading some guides of Unity networking, but I’d like to know if it would imply in drastic changes in what was learned in this tutorial.

    Thanks for the good work, you rock!

    1. Hey Lucas, I’m glad you enjoyed the project. Unfortunately the Tactics project was not designed with online multiplayer in mind at all. My experience with online multiplayer is also pretty small in general. I did write a “Tic Tac Toe” project to try it out in case you didn’t read that one yet – it at leasts ends with a working sample, but is still a long way off from an online multiplayer Tactics RPG. Keep in mind that there are other options for networking besides Unity’s built in option (which I frequently hear are much better, but for which I have no experience).

  10. I’ve been reading your other lessons and finding them very useful, they’re definitely helping me understand unity and coding more. Thanks you for all your work!

    That said, I have special interest in this tactics rpg lesson, I love the genre and want to do my own in the future. However it’s quite old now…hence my question:

    Is the current version of unity compatible with the materials/lessons/tips written here? I’m going to follow this series but I’m afraid of potential issues with the engine version.

    1. The current version of Unity is still compatible with the Tactics RPG project. I am amazed at how many people are still following along with it actually ๐Ÿ™‚
      One reason that it is probably compatible is because I focused so heavily on the programming rather than the implementation (art assets etc). There may very well be places that could be updated, but I haven’t personally gone over it with a fine tooth comb to decide where. If you encounter anything along the way, feel free to let me know!

      1. Just a shoutout kind of, take it as you will.
        First off, the tutorial is great so far! A lot of good examples and explanations on not just how to do but why to do certain things. I agree that more images would help clarify a few areas, however at the same time that leaves a little room for us to try and link the ideas before checking the final version.

        I believe that this gets so many hits due to two things.

        First, there really are next to zero good tutorials that go through making a tactics style game and connects the parts together. Extremely valuable to us learners.

        Second, your logic flow is very clear and you explain well when answering questions. This also is very hard to find.

        If you would be willing to go into this series more, adding a section on recruiting a character in game for example, map to battle back to map and track exp, etc this could really increase traffic to your blog overall.

        A very fine series and source for programming.

        1. Thanks for the kind words. I really enjoyed this project and might be willing to revisit it in the future. It might be a while though – I am currently trying to wrap my head around machine learning. I’d really like to understand it, not just make it work, and let’s just say I have a long way to go. I’d be all the more excited if I could learn ML well enough to make A.I. for a Tactics game like this.

  11. Um, how exactly do I run the game from the project zip? There is no .exe and unity can’t import the project for some reason. Is it missing a file or am I doing something wrong?

    I’m off to a great start, am I not?

    1. Extract the contents of the zip, then from Unity’s Project browser choose Open -> Select the folder containing the “Assets” and “ProjectSettings” folders and click the Open button on the dialog.

  12. Great tutorial! This is like magic, and is helping me make my dream of creating a tactics RPG come to life.

    Unfortunately, no matter what I do I get this error with the InputController script : “The type InfoEventArgs’ cannot be used as type parameterTEventArgs’ in the generic type or method System.EventHandler’. There is no implicit reference conversion fromInfoEventArgs’ to `System.EventArgs'”

    I still got this error even after I copy and pasted your InputController code into my script, and even though I can play your sample game just fine, if I do anything with the code, that error pops up ruining the downloaded game.

    Is there anything I can do about this, or will I need new code altogether?

    1. My guess is that your problem is not with the “InputController” class, but rather with the “InfoEventArgs” class. It sounds like the “InfoEventArgs” does not inherit from “EventArgs” such as in the following definition:

      public class InfoEventArgs : EventArgs
      *Note for some reason the generic type argument gets stripped out of my code snippets that appear in comments, so you should see a “less than, T, greater than” appear before the colon.

      Also, don’t forget the using System; line.

      1. Worked. Thank you so much! I was ready to abandon this tutorial, but now I don’t have to!

  13. Hey just discovered this tuto and im hoping to get started on it in the coming weeks, but since im kind of a newbie to unity and i’ve been seeing ECS being mentioned a lot lately. And it seems to be the next great thing. I wanted to ask should i first try and master ECS and then apply what i learn to this tuto or vice versa?

    1. That’s a really great question. There are definite pros and cons to both approaches. If you are a beginner, you might feel like the code here is easier to learn from than a pure ECS might be for you. As you get more advanced you may decide that you want the power and flexibility of an ECS, but you can work your way up to that, and Unity’s old architecture is not entirely unrelated (GameObjects have a similarity to Entities and Components obviously have a similarity to the ECS component), so you can think of it as a stepping stone.

      ECS is a really amazing architecture, and there are many ways you can approach its implementation. A couple of my tutorials on this website use a custom ECS implementation such as the “Unofficial Pokemon Board Game” series. Unity has recently added its own implementation of an ECS which I haven’t looked at in depth yet. It sounds like there are a few varieties on how it can be implemented, some of which sound a lot like the old way of working with MonoBehaviour scripts on GameObjects.

      Making a Tactics RPG is very advanced work (in my personal opinion) so unless you are also an advanced programmer I would expect it to be very difficult to try to apply the concepts properly right from the beginning. I would recommend following all the way through first as it is, so that you have a better idea about why things are setup the way they are. It will help you to make better decisions about how to refactor it all if you are comfortable with the entire feature set.

  14. Hi there, completely new to Unity, (the software and c#), but have a basic understanding of programming. I just downloaded the Tactics RPG ZIP and loaded it as a project into Unity Hub with Unity Version: 2019.3.0a5 and after doing a build and run I get about 50 warnings and 7 errors. I really just wanted to build the project and play it to check it out, but the primary error that appears to be stopping it from loading is: the name ‘AssetDatabase’ does not exist in the current context

    Sorry for my lack of knowledge, I know very little about reloading assets and all that jazz. Is there a quick way to load this project? My next plan was to just download the older version it was designed in, but if you know of a quick way to update it to the latest unity, that would be greatly appreciated as well.

    1. Regarding your error, the AssetDatabase should be ok – the online documentation doesn’t show it to be deprecated. I also just tried the same version of Unity and was able to open the project and play it just fine. I do see warnings, but no errors, and I dont see the one about the AssetDatabase not existing in the current context. It’s always possible that since this is an alpha version of Unity that you have encountered some sort of bug. Are you able to open and run other projects?

      Just a quick heads up, the zip file on the intro contains the prototype project from which the rest of the series is based. If you want the more complete version you would need to grab it from the project repository here, https://bitbucket.org/jparham/blogtacticsrpg/src then use the file menu and choose โ€œPre Production->Parse Jobsโ€

      Good luck!

      1. I definitely was using the prototype version, so I appreciate you correcting me there haha. That said, even after getting the version from the link you provided, and loading it into Unity, it still throws back the 4 errors for AssetDatabase. Before doing the build and run, clicked pre-production->parse jobs but that doesn’t appear to do anything.

        Again, very sorry to be a pain. I’m still doing a lot of research on how Unity even works, and since others are able to open this project, the issue definitely appears to be user error. Thanks for the quick response and if you can think of anything else to try, be sure to let me know. That being said, I plan on going through your tutorials for the project now, so I suppose I would see it all first hand anyways ๐Ÿ™‚

        1. I tried googling your error and the only thing I have seen so far is making sure that files using the UnityEditor namespace are put in an “Editor” folder (like literally named that) and to use preprocessor tags for all unity editor content like so:


          #if UNITY_EDITOR
          using UnityEditor;
          #endif
          // ...
          #if UNITY_EDITOR
          // some code here that uses something from the UnityEditor namespace
          #endif

          I “think” I’ve already done all of that for you (especially since it compiles for me) but if you’re getting files and line numbers along with your errors it might be worth checking out.

          1. I can add it to my to-do list, but Im not sure when I will get to it. If you are stuck on any particular error, feel free to ask about it here or on my forums.

  15. Basically I cant get the game to compile. I am on most recent build of Unity and get 4 errors that prevent it from launching.

  16. Hey!

    I can’t get this project to run. I’ve tried the full project (from bitbucket) in both the newest LTS of unity and the “recommended” one (5.3.1f1), and I did the “parse jobs” step mentioned elsewhere. However, when I run the game, nothing shows up. The camera is just staring at the sky, and there doesn’t appear to be anything in the inspector. All of the assets are there in folders, but there is no “game.” Am I missing a step somewhere?

Leave a Reply to thejon2014 Cancel reply

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