Sorry I missed out on the post last week. I didn’t have work for Labor Day, and that threw me off schedule, and I just forget. Never you worry though, I’ve got you covered today. Aside from some general housekeeping and refactoring, I’ve really focused on two major aspects of the game in the past two weeks: physics and rooms.
Relaxing the Bodies
When I initially set out to learn how to make a platformer in Unity, I tapped into my experience from working with Box2D on both In Vivo and my Ludum Dare 29 entry. I had it in my head that there was a right way to use a physics engine for platforming, despite all of the advice to not use a physics engine and just handle the collisions yourself. This started out really well. I had a collider for the body, to handle actually running into things, and some trigger colliders for detecting various states. There was a trigger beneath the main collider to determine if the player was standing on something, and was able to jump. Implementing ledge grabs introduced two more detectors, one for actually hitting the wall, and one above it so it could tell the difference between a ledge and a wall. As I went on to things like wall jumping, stalling, and various other acrobatic skills, the number of detectors ballooned. On top of that, there was a lot going on that I wasn’t happy with in regards to the general way it was handling movement. I needed a different approach.
After reading as many articles as I could find about platformers in Unity, I decided it was time to bite the bullet and actually roll my own physics code. Thankfully Unity makes this nice and easy on me, with things like ray and box casting to do the brunt of the math. Essentially, I let Unity handle detecting collisions, and then I step in and deal with responding to them. This also gives me a lot greater control over the way movement is handled, which means I don’t have to figure out the right mass ratios of my objects, or relative friction between entities and the floor. I don’t need that level of detail from my physics, I just need a guy to walk around. I have done collision detection and response in the past, and even written a physics platformer from scratch just to see if I could. This was a walk in the park by comparison.
A Place to Play
I talked a little bit about the map generation in my initial announcement post, but for those that don’t remember, it’s going to stitch together a map from a bank of possible room layout. I have done procedural level generation in the past, and I have a good understanding of how to make a map that can be completed with the ability gates that are inherent to this type of game. I haven’t started on that algorithm quite yet, but I have laid out the design, and I know I’m going to need a lot of rooms and a way to load them. I’m using the Tiled map editor to create my levels. I used it for In Vivo and for one my Ludum Dare entries, and I’m pretty comfortable with its ins and outs. I threw together a basic room layout using the shape layers and set to getting it into the game.
This is obviously just a bare-bones outline of what the levels will look like, and it’s missing things like item caches, secrets, hiding spots and doors, but it’s enough to test out the concept of actually loading levels. Up until this point I hadn’t attempted to get anything actually loading from an external resource that wasn’t a graphic. It wasn’t that difficult, though I did run into some file format issues. I used to build web apps, and I know the pain of the xml overhead all too well, so I had taken to the habit of exporting my levels in JSON format. It turns out that neither C# nor Unity have built-in JSON parsers, so instead of doing the obvious thing and using XML, I tried to find a good open source JSON library. After spending far too much time doing that, I snapped out of it, switched everything to XML and got the levels loading. Sure they were upside down and nothing lined up, but it was a start. After a few hours working out all of the bugs and making everything speak the same language, I had the level loading in game, and I was able to walk around in it. Success!
But What About…?
Previous to my foot injury, I had been working mostly on graphics, and that has come to a standstill. I’m very interested in using the Sprite Lamp tool to enhance my visuals from my shoddy attempts at 2D lighting, and I’m still trying to decide if I should go for it. In the mean time, I wanted to get something that people could actually play out sooner rather than later. It has been months since the announcement, and I don’t have anything playable yet. I’m hoping to get the fundamental platforming mechanics up and running and out to you all as soon as possible, so I can get the feel of movement just right. I would like for that release to also look pretty, but if I have to release it with a flat character and red squares for the ground, I will.
I’m hoping to make a decision on Sprite Lamp soon. It looks really nice on their site, and it can be used to great effect, like in Hive Jump (shameless plug: you should go pre-order the game, it looks very promising and I want the extra guns). As soon as I know if it will work with Spine in Unity I’ll have my decision, but since it changes the workflow I have to hold off on making things pretty for now. I’m pushing for a five-room demo, with all of the graphics, basic gameplay elements, and some sound within the coming month. It seems a bit ambitious, but now that I can actually focus on the project instead of the tools and framework, I’m hoping I can power through and start turning this crazy idea into a game.