DEV Community

Cover image for RTS game development - Week #3
Christopher Toman
Christopher Toman

Posted on • Updated on

RTS game development - Week #3


It's the third week and more work has been done.

The biggest thing is the terrain, units no longer move on a flat surface.

But, let's start from the beginning. Last week we did formations and their ordering. And we had said that we will make units rotate along their velocity vector. Also, squads which will be selectable through UI. All above has been done. Hooray!

Units now look along their velocity vector.

A couple of new formations: Line, Arrow, Double Arrow and Row.

Formation were separated into two interfaces. IFormationBehaviour and ISlotAssignBehaviour. And then there's the Formation class which binds these two behaviors together.

//creates different formations and its behaviours
var layerAssingmentBehaviour = new LayerAssingmentBehaviour() { InvertAngle = invertAngle };
var axisAssingmentBehaviour = new AxisAssingmentBehaviour();

formations.Add(FormationType.Box, new Formation()
    FormationBehaviour = new BoxFormationBehaviour(4),
    SlotAssignBehaviour = layerAssingmentBehaviour,
Enter fullscreen mode Exit fullscreen mode

A button for switching between individual mode and squad mode. Individual lets you select any unit through box selection. Squad mode has box selection disabled, but on whatever unit you click, it will select the whole squad.

UI for squads, ability to select any squad with one click. The upper bar.

Added terrain to see if the formations work in 3D. It had a couple of bugs with height, but it has been all fixed.

And finally... teams and attacking. Simple mock, just by right-clicking on an enemy unit it instantly kills it.

Attack mock

Some other little things...

Selection is not pixel-based but rather physical ray cast and position-based. Had an issue with different resolution needing different biases.

A minimap with a camera rendering from the top.


  • DoubleArrow formation still has its problems.

Features to add!

  • Unit individual movement and logic. "Autoplay", for example, Unit which is attacking and its target is out of range, it should start chasing it.

  • Unit attack. Ray cast and optimization. Visualization. How much accurate?

  • Curved formation for surrounding a target.

Top comments (3)

missamarakay profile image
Amara Graham

Hey there! You should tag this with #gamedev or even #unity3d. You'll get more visibility with developers working on similar projects!

k1pash profile image
Christopher Toman

Silly me,
I forgot to add it into the series and separate the tags with commas, they were already there in the input field. Thank you :)

missamarakay profile image
Amara Graham

I had a feeling something like that happened.