Wednesday, August 3, 2016

Creating a 3D City in Unity 5_part 1


Unity 3D is an open-source game engine used by indie developers and game studios. It is best known for its user-friendly platform, realistic graphics, and multi-platform publishing. This tutorial is great for beginners or anyone looking for a simple way to create a city in Unity.

Downloading Unity

Let's start by going to the Unity website. Unity 3D offers different packages. As an indie developer, their free package is exactly what you need to get started. Click Get Unity and download the package that is compatible with your system. Unity is both Mac and PC compatible, which makes it very popular. It is very important to check the system requirements. As of March 2016, they require a minimum of Windows 7 and Mac OS X 10.8 and above.


Next, you will want to register. By registering, you can keep track of your downloads and purchases from the Unity asset store. Once downloaded, Unity will start up. Depending on your system, it can take two to eight minutes. A dialogue box will open, asking you for your credentials. After you log in, it's time to start a new project.

Start a New Project and call it "My City". For the time being, do not choose any packages.

Pay close attention to the folder you add your projects, as all files need to remain in the same location. Keep the default location for this project. Once your project is open, go to File > New Scene, and name your scene "MyFirstCity".

Unity Interface

At first, it will be a little overwhelming, but don't worry—we will take it step by step in order for you to understand what does what. At this point, your window should look like the picture below:


Let's begin at the bottom.
  • The Project tab is where your project files, images, textures, and prefabs will go. It is good practice to keep your files organized from the very start. Games require tons of project files so it's better to start off on the right foot. 
  • The Console tab is where you will see any code or file errors. 
  • The Hierarchy tab will be where your current on-screen objects will be. Every project begins with a Light and Main Camera
  • The Scene tab shows your current scene through your main camera's focus. 
  • The Game tab shows you what your game looks like when it's being played. 
  • The Animator tab is where you will add your animator controller commands for your character.
  • The Inspector tab is where you will see your current object details, for example, color, texture, scripts, etc. 

The toggle bar contains the controls to move around in your world. Moving an object in the scene also moves it in real time on the game menu. Make sure you always save your scene to ensure your object stays in the position you want it. Let's go in order.

The Hand icon allows you to grab the screen and move in the world freely.
The Crossed Arrow symbol is used to move objects. In a 3D world, you can move up, down, left, and right.
The Rounded Arrows are used to rotate your objects.
The Outward Arrows are used to resize your object.
The Box gives you an eye view. When you right-click your mouse, it allows you to see in a first-person view perspective.
Across the top bar, we have File, Edit, Assets, Game Objects, Component, Mobile Input, Window, and Help. The best way to learn about the menu is trial and error. We will go through the menu step by step later in this tutorial.

Layout


When you first open Unity, you will see the above layout. Go to Window then Layouts, and you can view the different layouts available in the Unity editor. Click each one until you are comfortable with them.

You can also create your own layout by left-clicking the tab and moving it anywhere you want. In my case, I use two monitors so I have my Game Scene on one monitor and my edit Scene in another. Play around with it until you're happy!

Downloading Assets

Now that we've created our scene and are happy with our layout, its time to download the assets we need for our project. Keep in mind any asset you bring into your scene can be used for multiple projects.

Go to Window and click the Asset Store. The asset store will open; here you will see hundreds of objects, textures, characters, and unity tools. You can purchase any item you would like. Although for this tutorial I will show you how to create your own textures, we will also download free assets. When you open the asset store for the first time, it may ask you to log in.

Let's start by typing Yughues Free Concrete Materials in the search box. Your window will look like the below sample.


Now click Download. After a few moments, a box will open. Click Import. Depending on your system it can take anywhere from two to ten minutes. Once it's imported, you will see your new asset in your Project tab.

Now let's go back to the asset store and import the City Props Pack. Repeat the above instructions.

We will also be downloading a skybox. Go back to the asset store and import Wispy Skybox.

Now it's time for our Unity packages. Go to Assets > Import Package. We will need the Characters, Cameras and Environment packages.

Finding Free Assets

We need a road and building textures, so in keeping my promise of free assets let's go to the web. Go to Bing and type "road", and once some images pop up, make sure that under the License section, Free Domain is chosen.

Feel free to choose any road you like, but a road with no background or sides would be best. You can also feel free to open the image in your editor and remove what is not needed. I have attached the road I used for this tutorial.

To keep things organized, save your images in your Unity folder. You may need to find where your files are being stored; usually, the default location is Public documents in My Computer. Now we need approximately five building textures. Click this Bing shortcut to be directed to the textures I used for this project. Right-click and save in the same Unity folder.

Tip: Always remember when using your projects commercially, it is better to be safe than sorry. You can visit websites like Envato Market to purchase royalty-free images.

Now let's create a folder in our Project tab and name it "Artwork". Go to Asset > Import Asset and choose your image. Move your image into your Artwork folder.

Tip: If you move your image once you have saved your project, there is a chance your image will not appear or appear pink (without a texture). Once all of your assets are downloaded, we are ready to begin setting up our world. Let's click File > Save Scene.

Let's Get Grounded

Let's add our terrain. Go to Game Object > 3D Object > Terrain. This will add a 3D Terrain into the scene. Now is a good time to play with the toggle menu to get used to moving around the world.

Tip: If your mouse has a wheel, you can use it to move closer or farther away from an object by clicking the Hand icon.


Once you add a terrain, your scene should look like the image above. There are a couple of reports of shader glitches when first opening Unity 5. If your project looks like the image below, don't worry—we will fix it! We will discuss lighting in another tutorial, but for now, click Terrain, and then under the Inspector tab choose the Cogwheel, scroll down to Material, and choose Built-In Legacy Diffuse. This should fix the issue.
Written by:  Sandra Gerber

If you feel useful for you and for everyone, please support and follow us.
Suggest for you:

Unity 5 Professional Guide - Develop a 2D Arkanoid Game!

Unity 5 Professional Guide - Mastering C# Programming!

Make VR Games in Unity with C# - Cardboard, Gear VR, Oculus

Learn to Code by Making Games - The Complete Unity Developer

Start Learning Unity3d by Making 5 Games from Scratch



No comments:

Post a Comment