I got sick this week. I blame it on the salsa dancing where I go from a stupidly hot and humid dance floor to the outside night of Winter; it cools you down but I’m pretty sure the rapid temperature changes mess with the immune system to the point where the bugs get you.
And that’s what happened to me this week. Nothing crippling but enough to lose the appetite, have the usually pleasant coffee smell make you feel queasy and just general lethargy. Still, I went to the day job and managed to drag myself to the gym once my gut didn’t feel like crunches were going to make me throw up.
Hows that for an intro?
This week it was lots of preparatory work for being able to move my place-holder units around the screen. The goal was to actually get the ‘drag-to-path’ system in place using the style used in Autumn Dynasty but good old Unity-learning-curve and life’s distractions only made this a partial success. I finally made my own Unity prefabs (they’re so fundamental it’s any wonder why I haven’t used them until now) to represent each unit and it’s gotten to the point where the press/release will select/deselect them. I even have a picture…
The white circle is a touch-pressed unit and all the placeholder white lines are the paths that the units are currently following. Really basic and with lots of fun z-fighting problems.
The next is to drag a path from the unit to a desired location so that the unit traverses it. Currently I’ve just got hardcoded destinations.
Sounds simple, but here’s what I observed from Autumn Dynasty.
- When dragging the path line from the unit, the path line continually resamples itself, whether than be via simplification, smoothing or both.
- When the final path line is created, it might totally redraw itself depending on impassible terrain. For example, a straight line drawn across an impassible mountain range will change to a line that moves around the mountains.
- Multiunit selection and moving will draw multiple lines; the lines will converge quite early on.
- A path that has an end point in impassible terrain will crop the end of the path.
- An eventual path that the unit follows will be consumed as the unit follows it.
It turns out dragged paths are quite involved but Autumn Dynasty has a winning formula that’s worthy of copying (shamelessly). Thankfully there are some line simplifications libraries out there. I’ve already gotten my hands on a C# implementation of the Douglas-Peucker Line Approximation Algorithm.