Custom Component Based System

In this post I will present my own implementation of a component-based architecture which closely mimics Unity’s implementation. It really isn’t as hard as one might think. Why would I ever do such a thing? I think I have plenty of good reasons, but I’ll let you decide whether or not its all worth it. As always, feel free to critique!

Continue reading

Ability Menu

In this post we will continue to flesh out the UI by adding the Ability Menu. This menu will allow the user to determine what phase of a turn is active- such as moving, attacking, etc. as well as what to do during a turn- such as what kind of skill to use during an attack. We will actually implement the menu where possible (Move), and anything we haven’t gotten to yet will use placeholder content (Attack, Magic etc). We will also see how to support canceling a move and be able to restore an earlier state.

Continue reading

Object Pooling

Object pooling is a relatively common practice in games. By reusing your GameObjects instead of destroying and recreating them you can save precious CPU cycles. It is easy to find a lot of free scripts and tutorials on the subject – even Unity has provided one in a Live Training session. Their presentation, while a great introduction, was not what I would consider production ready. In this post I’ll share my thoughts on their implementation as well as how I would improve upon it.

Continue reading

Tactics RPG Conversations

This week we will implement the UI components from the previous lesson in a Conversation UI element which would appear as part of a cut-scene before and/or after battles. The panels will hold a little bit of text along with a sprite showing who is speaking. A bouncing arrow will indicate when there is more to read and using the input “Fire” event will cause the conversation to move on to the next message or the next character who will speak, etc. These panels can appear in any corner of the screen (which could indicate the direction of a speaking character relative to the player), and will animate in and out of the screen as needed.

Continue reading

Tactics RPG Anchored UI

The user interface (UI) is one of those areas you always end up spending a lot of time implementing, and every game needs one in some form or fashion. I have built up a variety of reusable libraries in the past, but with Unity’s new UI tools I find myself starting over again. If you’re like me, the anchor and pivot system provided by a RectTransform may have been a bit confusing. I like working with it pretty well in the inspector, because I can modify the anchors and pivot to any corner for easy placement. In code, it wasn’t quite as easy, so this lesson is dedicated to the creation of a few reusable components which will, hopefully, make all our lives easier for awhile.

Continue reading

Better than events

I’ve received some feedback regarding using event-based architecture in my recent post on my Tactics RPG State Machine. The concern is that because events cause extra memory allocations it could have an affect on performance. I’ve used events heavily in every project I’ve worked on and to date have never observed a performance problem on their account. Still, I was curious to run some tests and see just how bad it might be.

Continue reading

Tactics RPG Path Finding

Pathfinding can be a relatively advanced task, mostly because the logic takes a moment to grasp. We will be using a form of pathfinding to highlight all of the tiles that a unit can reach. When one of those tiles is selected the unit will follow the best path to the target. To make it more interesting, I will add three different movement types: a walking unit which must go around enemy units and tiles with too large a jump delta, a flying unit, and a teleporting unit.

Continue reading

Tactics RPG State Machine

This week we are going to create a State Machine which, over time, will handle all of the states which ultimately control our game’s logic. Initially I will create a state which is responsible for initialization (creating the game board, etc.) and then we will add another state which allows us to move the tile selection indicator around the board using events from our Input Controller. We will also add a simple Camera Rig to make sure that the game camera is always looking at something relevant.

Continue reading

Tactics RPG User Input Controller

In this lesson we will be writing a component to manage user input. We will work with Unity’s Input Manager so that your game should work across a variety of input devices (keyboard, controller, etc). The component we write will be reusable so that any script requiring input can receive and act on these events.

Continue reading