So, I'm staring at a blank project. Where do I start.
I'm not at a total loss because I have helped our 12 year old make an obstacle course or "Obby" in Roblox and as I had mentioned before, back in the 90s I wrote a 3D helicopter simulator in Amos 3D so I do understand 3D space (the fact that there's an X (left/right), Y(Up/Down) and Z(Near/Far Depth) and that everything on the interface appears to be an object within a tree structure starting with the scene.
- A Scene
- A light source Illuminating the Scene
- A main camera within the scene
- An Object (Such as a cube or sphere)
- A light Source Illuminating that Object
- A camera Following that Object
Even when adding properties such as a colour to an object, that colour seems to be its own object. For example, you can't just make an object metallic red, you create a metallic red material within the assets and then add that material to the object. If you add the material to multiple objects within the scene and then change that colour to green, all the objects that were red before will change to green.
By the way, one thing that has dawned on me about these posts that I want to make clear is that they aren't meant as a "How To"... I am learning this from scratch and may do things which simply are not the way that things should be done. This is merely a diary of the learning process I'll go through to create something that looks like a game. I am sure I will embarrass myself with my choices at some point and go back through it to do something better or the "correct way", so if you are expecting this to be a how-to style post then you're in the wrong place. I may do some actual "how to" posts on other subjects that I do have a better understanding of, such as Umbraco or c# but for this, sorry, you've been warned!😊
Put Something on the Screen
The game is quite simple in terms of graphics, for the actual gameplay I will require a road or floor, a motorbike, trees, enemies, bullets and a text box for the score. In the first instance, I will concentrate on the motorbike the user will be controlling so need a floor and a bike.
Creating the Floor
The floor seems easy, I need to create a cube, make it wide and long, flatten it and change its name to "Road". To do this seems simple, right-click on the scene in the tree and create a cube gameobject. Once created I can flatten the object using the scale tool
Success! I have a Road, but it doesn't look like a road because it's white. To make it look like a road I need to add a material to it... After searching for a little while I find a great site with all sorts of materials for unity objects called Poly Haven
Poly Haven has lots of materials which are free to use and there's plenty for me to use for a floor, so I chose a simple floor of grass and sticks and imported it into my unity project into the assets folder.
As mentioned before, I have to create the material for my road, which means choosing the material image file I have just downloaded. As well as an image file, poly haven materials include a height map file which you can add to the material which will make my floor look less flat. I add this height map to the material and now I have a floor which has a dirty, muddy, grassy look to it. If you're looking at the picture below then trust me, when I zoom into it, it looks a lot better 😊
Now, I need to add my motorbike
Adding the Motorbike to My Scene
I'm not going to get myself bogged down right now by having a lovely motorbike model on my game (that will come later). I want to have something which I can move about so I am happy with just a simple object for the time being. Repeating the process of adding the road, I created a cube and pulled the shape a little longer to mimic the general shape of a motorbike and set the material to a burnt orange colour (I like this colour, so that's what I'm going with)
The original 3D Deathchase plays from the perspective of the player sitting on the Bike, therefore the camera is directly behind the bike with a low view so that you can see the trees coming towards you.
To achieve this, I can position the main camera so that it is behind the Bike but slightly higher, and pointing slightly downward towards the Bike (I'm getting good at moving objects in this environment now). To keep the camera in this position you simply drag it within the tree so that it is a child of the Bike object and it will stay exactly where it is relative to the bike object... How cool is that!
Happy So Far
I have the floor with a nice material on it, a simple "bike" and a camera which will follow the bike correctly (in theory). I've learnt that everything is an object, I've learnt how to create objects and how to move them in 3D space and how to paint them a lovely burnt orange colour or give them a texture. I've also learnt how to move and manipulate the camera.
I think that's enough for today and indeed for part 2. In part 3 I'm looking forward to doing some actual coding which will make the bike move along the floor at speed, allowing the player to move left and right!
See you in part 3
If you find this article interesting, could you please do me a favour by sharing it or commenting below, I would love to hear your and other peoples' thoughts on this subject. Thank you
Date: 11 Oct 2022
Author: Craig Pickles (YorkshireTechy)