Project Johnston

Hello everyone.

This is Johnston, a temporarily named, turn-based tactical game, in the genre of XCOM, Jagged Alliance, Laser squad nemesis, Silent storm and similar, though naturally with a much simpler scope. There is no design document or story yet. This will be coming if I can make the core gameplay (small, fast-paced battles) fun. There is not yet much to look at, but I’d like to show it off anyway to get some feedback and to keep a log of development.

Step 1: Procedural terrain generation

Johnston has procedural terrain generation. It’s relatively simple and in only one level (no heights). To get there I first built a grid of tiles which were just simple cube primitive prefabs, with a special tile script and a grass texture:

I added a light that is automatically positioned over the tile that is below the mouse cursor. This is to give the player a clear idea what he is clicking on.

Next up was getting random types of terrain onto the grid, in a meaningful way. I did this by using an “ant” approach, which turned out to give quite decent results.

There is more info about how the terrain generation works in this thread:
http://forum.unity3d.com/threads/76335-Tilemap-generator-procedural-terrain-generation

Ultimately, I ended up with this:

The models for the trees, rocks, treestumps and similar were bought from Turbosquid for a few dollars each. I will probably be replacing a lot of them with the free Unity terrain asset package, as they seem to be nicer to look at.

Step 2: Pathfinding

Next up was pathfinding. I needed PC’s and NPC’s to be able to navigate the procedural terrain. I had no idea how to do pathfinding, so I initially looked at AngryAnt’s “Path” and Aron Granbergs A* implementation. Both of them were too elaborate, and complex for me. I didn’t understand much of the algorithm itself, much less the complex code packages from Aron / Angryant. To get a better grasp of pathfinding I thus decided to write my own implementation of the A* algorithm, as that would force me to understand the underlying mechanics.

After a few days of sweat and tears, I finally got it working with the help of Arzi and mike_mac on the Unity IRC channel.

There was a few odd bugs in the implementation as can be seen in the above image (the path taken was the shortest, but not logical). These got sorted relatively quick though, ending up in a successful implementation of A*:

Step 4: Refactoring time

Having finished the pathfinding, it was time to refactor the code base a bit, as it had already gotten unruly. I spent a few hours re-writing and documenting the methods, and restructuring the classes, to a point where it’s somewhat readable.

Step 5: Getting characters into the game

Now it was time for the fun stuff, getting characters into the game. I found some really good low-poly models on Turbosquid by a guy called Mr Necturus. They were nice to look at, already animated and very well documented. 35 USD later, I had a soldier model. It was my first time working with objects with animations, so it took a little while to get it going, but Unity made it a very easy and painless experience. I split up the model into the various animations, and plugged him into my scene:

Some hours later, the soldier was fully animated, and the pathfinding was working flawlessly.

Here is a video of the soldier running around in the procedurally generated terrain:

http://www.screencast.com/users/VitesseDigital.com/folders/Jing/media/c018e276-5e09-499f-a869-444df121c1be

Please notice it’s 21 MB, so don’t click unless your prepared to wait a bit :slight_smile:

Next steps are getting an enemy model into the game, and write the AI for that. It will initially be a very simple AI, that does nothing but chase and attack the player with melee. After that a bit of UI for letting the player know health and related info for his units.

Time spent on this project so far is around 59 hours, most of that naturally spent on pathfinding and the procedural terrain generation.

Hope you guys enjoyed the post, and be sure to let me know what you think. I’m very interested in any feedback. I’ll be updating it, as the project comes along.

Finished first version of UI today:

Hey cool, grid based stuff in unity. I was going to make a small game using a grid system but while it wasn’t hard it got pretty ugly in unity. Hope it works out awesome for you.

I think grid stuff looks pretty old right now…

Laying out a grid is a pretty important part of A* pathfinding, considering it needs that basis. Nice work with the game, it looks great.

Quite a few things got done since last. First of all I got a nice, animated 3D model of an enemy creature from 3DRT.com for around 50 bucks. Closeup screenshot below:

I also got implemented a simple, turn based system and wrote simple AI for all enemies. I’m aiming for a more fast-paced player experience than is usually the case for turn-based games, so I designed the turn system to allow all enemies to move at the same time, giving very little waiting time for the player.

Forest fight:

Video
Here is a video of the AI taking simultaneous turns here: http://screencast.com/t/pfOCFGCbXKL (25 MB, so it might take a while to stream).