• Register
Post tutorial RSS sneaker

A Maze Kit is a Level Design plugin for Unity3D that allows you to draw and generate mazes and other paths from pre-made rooms. It includes prefabs so you can start right away to draw mazes and use them in your games, but it’s up to you to improve or replace them so you’ve got a personal touch on the final result. This first tutorial shows how to generate and draw mazes with the kit. Next tutorials will focus on how to create game from the included themes !

Posted by on - Intermediate Mapping/Technical

To follow this tutorial you must have download A Maze Kit

A sample of a game produced with the Sneaker theme is available from its root. Open the scene named game in the Sneaker folder :

Select the theme
Set the theme as Sneaker (no space, use capital letters when needed).
Here, the package detects a wrong room size as we have some rooms that display things outside of their "should be" bounds. After setting the new theme's prefabs, change the Y size so it's 256 as below :

Once it's done, generate a new maze in the X and Y dimensions. Look at your generated maze globally by selecting it in the hierarchy, press " to focus the whole, then click on the Scene View gizmo so the X axis is pointing right.

Warning : this theme is side-2D only, do not use the Z axis to create rooms or you will have weird behavior (actually, missing rooms).

Add the player
The player prefab can be added like in the CubeShooter demo or automatically. As there's other scripts needed, we'll use the SetupPlayer script here so it does all, located in :

Add the SetupPlayer component to the maze GameObject in your scene, then select the player prefab from the Sneaker/Prefabs/_Other folder in the corresponding field in the inspector.

The default Spawn Position should be ok with the default maze parameters.

Click on Instantiate Prefabs to instantiate the prefabs : the new script instantiate also the player and add two scripts to the MainCamera :

  • FollowPlayer : make the camera follow the player transform, with a smooth move and a configurable forward position
  • Time Slider : an easy GUI to modify the timescale, setting the default TimeScale to 5 when starting.

Camera settings
This is a side scrolling 2D sneaker, so set the Camera with the following settings :

  • Projection : orthographic
  • Size : 512
  • Clipping planes : near = 1 and far = 100
  • Background : black color suits well

No rotation should be applied to this camera.

Hit the "Play" button : you're in !

Keys :

  • up/left/down/right (or ZQSD or WASD) to move the player and do contextual action

Context actions :

  • near a desk : down to hide under
  • near a closet : up to hide inside
  • near a door: up to open/close it
  • near a copier: up to jump on it (it does not hide you from guards !)
  • near a ladder : up/down to climb up/down

Try to find the green desk and avoid all guards !

There's a building prefab allowing you to add a complete look to your game, just drag it on the scene.

2D with Unity : prefabs from this theme used an included simplified plane (only two triangles) and can be used without external plugin. But if you consider building a theme like this or using it in a real game, beware of performance issues : you should use a specific 2D package like NGUI, 2D Toolkit, ex2D or any other tool that fits your needs.

TimeScale and Physics
Why does this theme set the timescale to 5 by default ?
This specific timescale allows the game to run well while having a more arcade-style physic behavior (not still very arcadish though) and being able to use the physic engine.

Try setting the timescale to 1 and you'll see how slow the character falls from the ladder (the guard and player horizontal speeds are script parameters so you change change them with whatever value you want).
You could reduce the scale of every prefab (rooms, guards and player) but you'll encounter soon enough physic issues as a player that falls through the floor.

Different solutions exist to work with those behaviors, but this is not what this package is about, we let you decide of what fits your needs for that !

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.