Tuesday, 14 May 2013

Transforming Floors and Dressing Levels

Something I was excited about when I started this blog was being open about things. So in that vein, here is the first of hopefully many dev posts where I dig into how we're making the game a little.

When we released the trailer, the best reactions by far were to the level with the changing floor.

not pictured - serenity

It's a useful mechanic, changing the level configuration lets us take the player from a scenario where they are closed in and protected to being wide open, and it's a great visual, mostly because people are convinced the floor is going to fall away underneath them. (it won't, it's good like that, it'll wait for you to move away)

The trick was realising that each block only has three meaningful states - missing (a cavity) raised (a wall) or flat (a floor). That gives nine transitions (eight if you disregard missing-to-missing) so when Sanatana built the whitebox prototype, he created a cube prefab with a set of animations on them and laid them out in a 15x11 grid to form the level. Working in this way he had the entire level working and playable with simple blocks sliding up and down.

When it came time to dress the environment, I modelled up a 'block' consisting of a number of panels, but occupying the same space as the prototype cube. Next I animated the panels moving from one state to another to give the whole thing a bit of life, and exported it as a skinned mesh with single bone weighting and dropped the whole thing in over the top of the original prefab.

When the level changes, the physics updates instantly, but we delay the block animation based on the distance from the nearest character. This causes the transition to sweep outwards from the player like a ripple. (bonus exercise, think about how this works in multiplayer and why I said "nearest character"!)

Sanatana wrote a script to control the position of each block based on a texture lookup. This is a powerful technique, as he was able to open the level layouts in Gimp and adjust them as needed, making iteration very fast.

one of the 15x11 pixel textures pictured in the insert, and the level it creates

Also, I've been making steady progress on level art, here are some recent before and afters!


World 2 Stage 1 - Hive





World 1 Stage 0 - Tutorial



That's it for now! If you like what you see, please spread the word!

1 comment:

  1. This is amazing!, thank you for sharing!,
    This mechanic really ads dinamic to the game, it also feels like high tech.
    I was wondering how did you change block state according to pixels in a Texture,
    Did you use something like GetPixels()?
    Thanks, Alonso G.

    ReplyDelete