UNITY 3D MAZE GAME
Unity3D is a game engine. Game Engines are a collection of tools to help game developers. Unity3D includes tools to make terrains, basic prototype objects, lighting, controllable player objects and artificial intelligience systems for creating and controlling enemies.
The process of creating a game in Unity3D is very complex task. Rather than open exploration, I provide instruction in small blocks. Students forucs on creating Terrains, then setting up a "player, then simple 3D models, such as a targets and a maze. The game is a target shooting challenge, with the possibility to introduce enemies in the form of Skeleton Warriors at the end of challenges.The code for these features is introduced in sections, but uses a real programming language, C#.
A First Person Target Shooting Game Prototype Level with Bonus Features
- Level Map Design:Photoshop graphics, or pencil and paper sketch. (1/2 hr with prior experience)
- Outcome:Explore the process of creating prototype levels with appeal
- Outcome:Explore the potential for storytelling in a game context
- Outcome:Develop mechanical and digital drawing techniques
- Terrain Editing
- Outcome:Create a 3D terrain
- Outcome:Create topography including flatlands, valleys and mountains that limit travel,
- Outcome:Create texture map to add the visual illusion of rock, grass, sand, forest leaves, etc
- Outcome:Add vegetation to the map, including trees with colliders, and "detail" overlays of grass, ferns, etc.
- Outcome:Create a Sun by adding a directional light
- FPS Character, Movement & Camera(2 hrs.)
- Outcome:Import and tweek controls settings for a First Personal Controller
- Outcome:Add a skybox to the FPS Camera
- Environmental Models (2 hrs)
- Outcome:Import and set up models for a platform and target
- Outcome:Create and import a model for a Maze
- Outcome: Create and/or import other basic geometric models
- Outcome: Create or import materials, and import or create textures for all models
- Goal Objects, Obstacles.(2 hrs)
- Outcome:Create or import features to create additional challenges
- Outcome:Create programming to throw objects and hit targets
- Outcome: Create programming to track scores and achievements
- Challenge Outcome:Create programming to move platforms or activate enemies.
- Particle Effect Systems(2 hrs)
- Outcome:Create Particle systems for environmental effects, ie volcano smoke, or snow
- Outcome:Create explosion effects for maze targets.
- Outcome:Create programming to play sounds,instantiate explosions and perform 'garbage collection', the removal of objects from the game that are no longer required.
- Graphic User Interface.(2 hrs)
- Outcome:Create a display system for scores and messages
- Outcome:Create an opening scene with a title and play button
- Challenge Outcome:Create programming to move platforms or activate enemies.
- Sound:Selecting, importing and settings for sound.
- Outcome:Maintain legal rights for sound artists
- Outcome:Use correct methods of editing and importing sounds
- Outcome:Add environmental and event sounds to enhance game experience
The Game Development Process
These topics are outlined in more detail below. Click on the topic heading to expand or minimize the contents.
Level Design: Game Map[+]
Click on the map to play the sample game
This game features a fantasy landscape. I encourage students to divide their game 'world' into islands or land areas with different geographic and climatic features.
As game development progresses, storytelling within the game can be developed through User Interface (UI) elements that deliver messages. Games with an increasing level of difficulty, surprises and variety in the setting and challenges also build up involvement in the story of a game. The basic story for this project is a framework on which a more elaborate story can be constructed. The player arrives in the game, gains abilities and faces a number of target shooting challenges to beat the game. These events could happen on a deserted island, or another planet or a lost city. There is enough flexibility for students to use their imagination and have fun.
Intro to Unity [+]
Before beginning this project it's well worth the effort to review the first videos in Unity's Learn section, especially the beginner section functions of the editor, the secondary lessons on using the interface, and the rest of the first five videos up to Environment Details
When starting this project, I like to lead students through the process of starting a new Unity3d Project. During the install process, they will be asked to set up an account with Unity3d. Make sure they use an email address that they can access at school or they will have difficulty activating it. This gives them access to the Asset Store, where there are a lot of free models, textures etc. Be very cautious with the assets store, downloading some assets or entire projects can severely damage a project. I keep a separate bare bones project just for importing from the Asset store, that way I can prevent unexpected damage on my working projects.
Student projects should be created in a location that you have access to. This is essential for marking and support. (My lab is a Mac lab, students create their games in their Public folders. I use Apple Remote Desktop to view project folders and trouble shoot, but really, you need to be engaging the students in conversations. If you want them to succeed you have to know where they are and show them how to move towards the next step.)
For this project, we use something from most of the standard asset packages. The only one I leave out is the vehicles, and additional device inputs
Scene Setup [+]
Unlike with Scratch, we can safely leave the creation of a Start Screen and UI until later in the process. This is because Unity3d projects are based on Scenes, files with .unity extention. These files are the equivalent to game levels, so we can create our playable level, then add a simple start screen and play button in a separate scene later on. Even better, with Unity 5.3 or higher you can have multiple scenes open at the same time. When a project is started, a default scene is created with a camera and a directional light.
Before proceeding into Terrain editing, I recommend you set the Build Settings right away. Go to the top menu and select File Build Settings, then select what platform you want to target.
We use the Web Player and the default Player Settings. You don't have to add your scene or do a build at this point. Just close the build window. In the Game tab, you can set the window to 960x600 to see your project as it will look in the player.
Unfortunately, thanks to Google, the Unity Player is being phased out. The current alternate the Web GL build leaves a lot to be desired.
Terrain Settings [+]
To start creating a game world you can add a Terrain Object from GameObject>3D Object>Terrain.
In the Inspector, with the Terrain Object selected, click on the gear icon to change the Terrain settings
A terrain of 500 to 1000 is plenty for this project. 500 will be a compact world, 1000 gives some elbow room for mountains and valleys and other terrain features.
The rest of the process for terrain creation is presented online in a lot of different forms, so I'm not going to repeat it here. See the resource links above. I will just note that the Asset Store is good for trees, materials, and textures for terrains. You can also use Unity3d's Tree Creator by going to GameObject>3D Object>Tree. See the Unity Manual for details of that process.
The terrain should have distinct areas set up for different challenges, and there should be two areas left open without trees for the first targets and the first Maze. The reference sections section on terrain editing notes keyboard shortcuts such as 'alt/option' to rotate, 'q' to move the editor camera view and 'f' to focus on the current brush. These really help to speed up the process. If you have Wacom graphics tablets, these are great for terrain sculpting.
FPS Character and Settings [+]
One of the tabs in a Unity Project is the Project folder which contains the standard assets we imported when the project was created. Inside the Standard Assets/Character folder there is a FirstPersonCharacter>Prefabs>RigidBodyFPSController. This controller will be the Player character in our game. Even at this stage you can drag and drop the pre-fab RigidBodyFPSController onto your terrain. Double click on it to focus on it and move it so that the whole object is above the ground. Make sure to select the whole object not one of the child objects. If you click on the play button, you will see your world through the camera attached to this FPSController.
The characters forward, backward, strafe(sideways) speed settings as well as the jump force and other settings can be controlled on the RigidBody First Person Controller Script in the Inspector. I recommend a forward speed of 12 and a jump force of 80. You can run holding down left shift.
Environmental Models [+]
For our maze projects I have permission to use some premade assets, some with built in animations. These first targets could also be created with 3D objects with rigidbody components added.
The platform and targets we use are part of a Unity package "CoconutGame" which I distribute to students. A simple substitute for these animated targets would be to create GameObject>3d Object>Cylinders as target stands then size and place a 3d Object>Cube on top of them. If a rigidbody component is added to the cube (not the cylinder)the cube should be hit and fly off the cylinder once we have object throwing or "shooting" set up.
For our animated targets, we import the CoconutGame package usings Assets>Import Package>Custom Package>then browse to the CoconutGame.package file. This package includes models for a platform and a target. These should be set up close to the point where the player will arrive in the game
The other required model for this project is a Maze model. We create this using Cinema4D, if you are using other software, look for resources on creating meshes from bitmap images. Maya for example can trace the image as a Planar object then extrude it. For the Cinema 4D method, see this MazeModel page.