Developing Maze Game Components in Unity - Part 1
In this tutorial, we will discuss step by step, how to proceed with the development of some components of the game. These components of the game and the logic associated with each one of them is important to understand. We will start with moving a simple game component which will be our player or the lead object for this game. Yes, I'm talking about the ball, the ball which has to cross the maze. Come on, buckle up!
Start developing Game Components in Unity
Follow the steps mentioned below to develop a simple game component. Our game component will be a ball, and we will learn about its various properties where we will add color, adjust its size and then later move the ball using the cursor keys of our keyboard.
Some quick points to remember,
- Open Unity 3D (4.5 or above version).
- Check all the menu option once, just to become friendly with them.
- You can save the scene of your project by going to File → Save Scene and give it a name and appropriate location.
Now let's start working on Game components
- Go to File → New Project.
- Give your project a name, we think Ball-Motion is a nice name and set the path where your project will reside.
- Go to GameObject Menu → 3D object → Plane. You can also get that from the hierarchy view using Create menu.
- From the hierarchy window pane, you can give your Plane a new name - example ground.
- You can reset and transform components from the Gear menu under Inspector Pane and click Reset option. This will place the game object at the position
0, 0, 0 which is also the origin of your game world.
- Now if you want to change the scale of your plane, you can do it in multiple ways. You can directly select the scale tool from the toolbox, then grab the axis handle and use your mouse to change(move) it. You can also select any one of the three colored (red/ green/ blue) axis for changing the size of the object. You can do this for any object.
- Now in our ball game, our ball (game object) will act like the player. To bring this ball into picture, Go to GameObject → 3D object → Sphere.
- You can resize it by selecting scale tool and then dragging its three dimensional axis or from the inspector pane, just change the scale.
- Now drag the ball upwards so that it just touches your pre-existing plane/ground which you have already created. Doing this will move your ball over the plane after the movement related C# coding is done.
- By default there will be light and camera positioned in your Unity Scene.
- To add color or texture to your game objects (here plane and sphere), you have to use materials. So to keep the materials create a new folder in your project. Go to Project pane and select Create menu and then Folder. Rename it as Materials. Again go to, Create → Material → and give it a name....
- Just like in the above figure, you can create materials, the select that material, click on Albedo (which holds the whole range of colors) and choose any color and give each of your game objects a different color. To associate that color to your game object, you have to drag that material onto the game object.
- You can change the color of the material whenever required.
In the next tutorial we will learn how to move the ball and pass it through some randomly placed cubes, which will later form the maze. All these things will be designed and coded, and you will have lots of fun during this basic game component development tutorial.