My AssetStore Link


Unity Store Link - Click to see all the Song's work that has been put on Unity AssetStore

Thursday, 1 May 2014

Prototype of a RTS and Unity Navmesh Pathfinding

I've fell quite behind the curve if I'm honest. I'm pretty much still stuck with Unity3.5 for the most part, due to the none backward compatible nature of Unity and the need to support my package (TDTK,TBTK and InputTouches) for 3.5. Until recently I've shifted to 4.2 to take advantage of certain new features for the more recent project. Even then, I'm still clueless when it comes to mecanim, the new sprite system and what have you.

So I took a day break from my usual grind to try on new shinny things that I haven't try before. I start with the navmesh generation. Generating a navmesh is easy enough. Minutes later I've started to script a very simple chase agent. Before I know it, I have a simple prototype that very much resemble what I have in footman, only it runs a lot more better because I've learn how to code properly since the infancy of my game-dev days. And more importantly it has a proper path-finding system and more advance collision detection and avoidance.

Quite satisfied and impressed, I push on to see if I can do a RTS style unit command. It goes without saying, that opens the flood gate and this is what I end up with, so far.

It's not a full game obviously but pretty much all the basic elements are there. Building construction, unit building, melee unit, range unit, builder unit, attackable building, unit command, etc.. Forgot resource gathering maybe. When I decide to take a break from my MechCorp again I guess.

So back to the point, Unity navmesh is pretty awesome. It would be perfect if the navmesh can be dynamically updated/edit in runtime but that seems to be a pro feature in 4.3. But you can still get quite a lot out of it. A RTS even. but you will need to compromise a bit. For RTS, that means buildings can't be placed too close to each other. There needs to be a gap large enough for the agent to move through or they will simply got stuck between building. Then you can only use NavMeshObstacle on the building to block any walkable area. Which restrict the building footprint to a circular area, which occupies much more space than it needs to avoid unit clip into building. Put this two together, it means that the building must be placed quite far apart. much more than what it seems to be visually optimum. Even then the unit navigation may still get a bit wonky when trying to move through an area with concentrated building placement.

All this bring me to another delicate matter, PathFinder. I'm afraid the simple fact is it has became obsolete. Unity navmesh is simply a better solution. I'm considering to take if off AssetStore. Hope that doesn't cause any issue or upset anyone.


  1. Looks really good. Couldn't you do buildings that have a circular Area at the bottom but with a bigger building on top? This way the Buildings could at least look like being not that far away.

    Anyhow, it's a very impressive Demo. Can we expect a RTTK next ;)

    1. I suppose having a building with bigger tops could be a nice visual trick to hide the short-coming.

      No sure if RTTk will be a thing yet. Making a quick prototype for fun is one thing, making a full fledge package that match the standard of TBTK and TDTK is an entirely different undertaking. We'll see how this go. If I can, I will. The idea is always there, but it's way more challenging anything I've done so far. Otherwise I would have done it long ago.