Home > Game Engines, Games, Programming, RTS, Unity 3D > RTS Development using Unity3D

RTS Development using Unity3D

I spent some time back in September working on a RTS skeleton, just a barebones minimum RTS style game. I had a scrolling camera, with auto-height adjustment depending on the elevation of terrain the camera was currently over, along with proper collision detection and object selection. I ended up pausing from the project, as it was a collaboration project, with myself and a few other people planning on working on it together. The team needed more time to prepare for it, so I spent my time focused on Mud Designer and my wedding.

Things have calmed down now, and the main point of contact for the team looking to work with me on a 3D RTS game has resumed discussions with me regarding the project, so I thought I’d use this blog as an output to my thoughts and progress made. Not so much content related to the game, but rather how I achieved certain tasks that I was attempting to get working.

The first order of business for this morning was looking at what I had already developed. I had a working camera, and object selecting was implemented, so the next step would be creating units.
I figured the best solution would first create the units, then work on writing a manufacturing class that would perform the actual unit creation during run-time.

The Unit creation went pretty quickly, I created a BaseUnit class that all Units will inherit from. This way, as designers want new Unit Types (Marines, Monsters, etc.) they can create an extended class, edit a couple minor things (such as 3D model and sound) and the actual unit creation would be handled by the base type along with the AI.

I’ll probably end up moving the creation of the unit out of the BaseUnit class and into the Manufacturing class at some point, but for now this gets the job done.

It wasn’t difficult to get the unit created, albeit nothing is actually visually created on-screen. Basically I check for how much time has passed, and when the BaseUnit.ManufacturingTime has passed, the unit is flagged as created, at which point the user will have access to them.

//How long in seconds it takes to manufacture this unit.
    public int ManufactureTime = 15;
    private float manufactureStartTime;
    private float currentTick;
    private bool manufacturingCompleted = false;

    // Use this for initialization
    void Start () {
        manufactureStartTime = Time.time;   
        currentTick = manufactureStartTime;
   // Update is called once per frame
    void Update () {
        float manufactureTick = Time.time – manufactureStartTime;

        if (!manufacturingCompleted)
            if ((manufactureTick >= ManufactureTime) && (!manufacturingCompleted))
                manufacturingCompleted = true;
                print("Manufacturing completed.");
            else if ((int)currentTick < (int)manufactureTick)
                print ("Unit Manufacturing in process…");
                currentTick = manufactureTick;

The next order of business is to create the manufacturing class itself. I’ll probably move this code into that class, but for now this works out alright.

  1. DragonElite13
    October 10, 2011 at 4:50 AM

    what type of game is this is it medieval is it futuristic?

  1. January 2, 2011 at 6:40 AM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: