Project: Gauntlet - Current Iteration

Wednesday, November 25, 2009

Progress: Day One - Procedural linear level generation in Unity with C#

As we drop a big old Progress bomb on you - the Internet Civilian, bear in mind that we all work fulltime jobs here - in one capacity or another... we do what we can, when we have time... and when we don't have time, we take the Laws of Space and Time and we shake them like a crying baby.

Progress progress -

Wrote up the path-generation system in faithful C#.
The algorithm will take a predefined worldspace (as a grid width and height), a path length, and will hack a path within this world-space that follows these rules:
  • Right-angled turns only - no diagonals
  • No path node may be adjacent to any other path node, with the exception of it's single parent and single child.
You would really think that this would be a smashingly easy task - but in my sleep-deprived state, it proved to be quite a logical trick.

Strangely, it was more difficult to exclude diagonal turns than it was to include them.

In any case, with this algorithm completed and extensively debugged (as extensively debugged as a randomly-generated path can be) - the presentation layer was developed in Unity.

Effectively - the algorithm will provide Unity with:
  • All coordinates of the walkable path
  • All coordinates of nodes that border the path.
With this information, the presentation layer:
  • Builds walls around the path from Prefabs (cubes in this case).
  • Builds a ground for the path from Prefabs.
And here is the baby - screenshot from within Unity inset with debugging work in Excel (conditional formatting is a winner).

All in all, not a bad day of work.


No comments: