• entries
    42
  • comments
    139
  • views
    50842

Unity Turn Based Combat

Sign in to follow this  
Eck

1470 views

Personal Update


I'm still working to finish out the month at my job. We have a four month old and six month old puppy (Malcolm and Serenity) who have been a bit of a time sink. Plus they've torn up the carpet in the living room and the linoleum in the kitchen accelerating the time schedule for needing new floors. That project is going to take up a lot of my time too. But I'm making sure to dedicate time for game development.

BadDogs.jpg

Turn-Based Combat


The turn-based combat is going to be one of the main fun (hopefully) items in my game, so I decided to start with it. Last week I got a simple turret/laser effect going. This week I put some scaled cubes together, slapped a turret on top of them, and called it a ship. A turn-based combat system is more complicated than I gave it credit for, and starting with it in a blank scene made it a little tougher. But I put in some extra time Friday night and got things working.



So far I have a list of Combatants that are controlled by a team (Human/AI). I have some ship stats with health and lists of weapons with damage. A basic combat menu. Attack animations that trigger sound effects and apply damage at the right time. And victory/loss conditions. But it's still VERY BASIC and more than a little hacky.

I still need health bars, target selection, weapon list, floating combat text, ship movement, different weapon types (missiles, mines, projectiles, fighters), different ship types, customizable ships, weapon modifications, ammo, critical damage, better combat mechanics, ship movement, weapons arcs, shields, defensive countermeasures, and a slew of other features that are too numerous to list.

Next week I'll be continuing to work on the Turn-Based Combat mechanics and visuals. I plan to get some sort of health indicator like a health bar and floating combat damage text. I'd also like to destroy the ship in some way instead of just leave it there. If there's time I'll try to get a couple of different weapon types going and maybe a couple of different ships too.

My Development Process


Before writing any code, I use paper and pencil to analyze and solve the problem. Then I'll code a little, design a little, and code some more. Then I hack the crap out of it until it works. Lots of developers stop here, but they are bad and they should feel bad! angry.png At this point I now see all the moving parts and have a much clearer understanding of the problem, and I'll go back to paper and pencil for some redesign. And then refactor my code into something I'm not ashamed of.

Right now, the turn-based combat system has some hacky code bolted together, but I'll be cleaning it up after I get a few more things working.

A Tip from your Uncle Eck


I love Unity but one of its problems is the editor crashes sometimes and everyone I know has lost some work. I found a script similar to this when searching for some auto-save functionality and so far, I love it. Any time you run a scene, it saves the project/scene for you.

Put this AutosaveOnRun.cs script in an Editor directory:using UnityEditor;using UnityEngine;[InitializeOnLoad]public class AutosaveOnRun{ static AutosaveOnRun() { EditorApplication.playmodeStateChanged = () => { if (EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPlaying) { Debug.Log("Auto-Saving scene before entering Play mode: " + EditorApplication.currentScene); EditorApplication.SaveScene(); EditorApplication.SaveAssets(); } }; }}
Sign in to follow this  


2 Comments


Recommended Comments

"I love Unity but one of its problems is the editor crashes sometimes and everyone I know has lost some work." Unity is a joy ride...

 

Eck, you're taking the concept of "journals" to a whole new level. Adding puppies is an instant upvote :P

Share this comment


Link to comment

I'm not proud! I'll stoop to puppies to sell my game if I have to...

 

They're the main reason I won't be producing much this week. I'll be installing laminate wood flooring in the kitchen and living room to replace the damage they did. :P

 

RIght now I'm not really sure what my journal is. It's part diary, part dev log, and part self-motivation tool. Hopefully some people will find it interesting, entertaining, or useful.

 

If you haven't done so already, put that script in an Assets/Editor folder Migi0027 (????).

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now