Home and Learn: Games Programming Course
In the previous lesson, we created a new 3D game project with a simple Plane object. We then imported a first person controller so we could walk about. We also set up the cameras. However, it looks incredibly dull just walking around on a flat, grey plane. So let's download some free stuff from the Unity Asset Store.
From the Window menu at the top of Unity, select Asset Store. Your browser will launch and take you to the Asset Store home page. From the 3D menu at the top of the store, select the Environments option. You'll get lots of results back with environments you can download. Most are ones you have to pay for, which is fine, if you can afford the price - there's some really great stuff on there. But look for the Pricing option. There should be a box you can check for Free Assets. Have a browse. The one we'll use is by 3DShapes and is called Colonial City LittlePack. It can be found here:
https://assetstore.unity.com/packages/3d/environments/urban/colonial-city-littlepack-163089
(Sometimes, creators will withdraw a free assets from the store. If the above pack is not available, download a free environment of your choosing. The advice below on magenta materials will still be valid, whichever environment you download. As will all the lessons in this entire section.)
On Assets Store web page, click the button to Add to my Assets. The Package Manager should open in Unity where you can download the asset:
Once downloaded, you need to click the button to Import it into your project. Once imported, it should look like this in your project area at the bottom of Unity:
However, double click the Materials folder and you may see this:
If you see assets that have turned magenta like this, it means Unity hasn't converted them properly to the Pipeline you're using (Universal Render Pipeline, for us).
To fix the problem, SHIFT click to select all the materials. Then from the menus at the top of Unity, select Edit > Rendering > Materials > Convert Selected Built-in Materials to URP.
Once they are converted, the materials should look like this:
To make sure that all the materials are applied to things like Prefabs, which we'll need, right click on a blank area inside of the materials folder. From the menu, select Reimport All:
Unity will display a dialogue box asking if you're sure. You are, so click the Import button. Unity will restart. When it's up and running again, you should find that your materials and prefabs are all good.
Move inside of the following folder:
Assets/Colonial City LittlePack/Colonial_Graveyard/Prefabs/Graveyard
The Prefabs should look like this:
(Don't worry if your streetlamp is still magenta.)
To start creating a scene, drag and drop the Prefab called Graveyard_Ground into the main scene window (second from the left on the bottom row, in the image above). Drag and drop it onto your Plane. Increase the Scale of your Graveyard Ground. We made ours 7 for the X, and Z values. (Make sure the Position values are all 0.)
You can delete the Plane object from your Hierarchy.
Start with the Church. Drag and drop the prefab onto the Graveyard Ground. Change the scale of the Church, as it will be too small. We went with a value of 7 for the Scale X, Y, and Z.
Now move the church into position. You can see an area reserved for it at the bottom right of the Church Yard ground. We set the Position values in the Inspector for our church as 0.25 for the X, 0 for the Y, and -1.2 for the Z:
As you can see in the image above, there are 5 raised areas where you can add the grave prefabs. Drag and drop graves from the Graveyard Prefab folder onto the raised areas. This may take you some time but, as a solo developer, it's one of the many things you have to get used to doing for yourself. Here's ours, if you want something to copy (the white lines above are where the player and the camera are):
To get walls surrounding your Graveyard, you can drag and drop one wall then, in the Hierarchy, duplicate the first wall. If you turn snapping on at the top of Unity, you can align the walls a lot better:
Click the dropdown arrow to set the grid settings:
For the Grid Size, where it says 1, try a value of 0.5 for the snapping. Now, when you move a wall with the blue, red, and green arrows in the scene, one wall will snap to another, depending on your settings. Remember to toggle the Grid off, if you don't need it, as the snapping can get annoying when trying to move other game objects.
After a of time, you'll have a scene that looks something like the one in the short video below:
Now that we have built a scene to walk around in, we can add a gun in our player's hand and start shooting!
Get the Player to Shoot a Gun -->
<--Back to the Unity 3D Course Contents Page
Email us: enquiry at homeandlearn.co.uk