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.
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 !
- 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 !