Difference between revisions of "Getting Started - No Scripting"

From __space Wiki
Jump to: navigation, search
(Primitive 3D objects)
 
(84 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
[http://space.apps.uri.edu/wiki/index.php?title=Learn_Unity_First '''Main guide page''']
  
= starting a new world =
+
Please Note: This page is a work in progress and may not be 100% correct or complete. If there are any questions or clarifications is needed, please ask! Questions are welcome and will help make this guide better. There is no need for coding knowledge to do any of the things listed in this part of the guide.
Make an account at https://unity3d.com/, Unity will probably ask you to sign in before you start doing anything with their application.  Once you've done that and signed in, you can go to 'New' and see something like this:
+
 
 +
 
 +
=Downloading Unity=
 +
The personal edition of Unity is capable of meeting any needs one may have for practice and or enjoyment, it’s free and is the version recommended for beginners. Unity policies states that if a developer earns an x-amount of money, they are required to purchase one of the non-personal editions. The non-personal editions offer a better server for multiplayer games, cloud support, etc.
 +
 
 +
Once Unity is downloaded, start the Download Assistant and accept the licence (choose the 64-bit version). For the components to include, it is recommended to have Unity, Standard Assets, and Build Support for whatever system(s) being used for game play/use.
 +
 
 +
= Starting a new world =
 +
Open Unity and sign in to start, then click on 'New' (To make a Unity account go to https://unity3d.com).
  
 
[[File:UnityNewScene.png|500px]]
 
[[File:UnityNewScene.png|500px]]
  
You don't need to worry about Unity Analytics or Asset Packages yet, and this guide is for making 3d games with the Unity engine, so keep that option checkedPress 'Create project'.
+
Name the project in the Project Name field, and pick a save location for the project. This tutorial is for making a 3D game, so select that option, if it isn't already selected. Do not worry about Asset Packages or Unity Analytics yetSelect 'Create project'.
 +
After everything loads, a popup may appear asking to update Unity. (If so, accept.)
 +
 
 +
Once any updates are complete the screen should look like this:
  
You should now be looking at something like this:
 
  
 
[[File:UnityDefaultLayout.png|900px]]
 
[[File:UnityDefaultLayout.png|900px]]
  
 +
=Manipulation of the Camera=
 +
To pan the camera hold down middle mouse click and move the mouse around. You can also rotate the camera by holding down the Alt key and moving the mouse around.
 +
 +
= Overview of editor and various tabs =
 +
 +
The following is a list of all the UI tabs you might have to deal with:
 +
 +
[[File:uiWindows.png|200px]]
 +
 +
This guide is going to talk about the most important tabs, but feel free to look up the others and explore.
 +
 +
===Scene===
 +
This is where everything that the player sees in the game can be edited, like objects' positioning, rotation, and scaling.
 +
 +
===Game===
 +
The view that lets you test out gameplay. It shows the initial view of the main camera.  It is almost useless until you press play, at which point you will be able to move around the world and interact with objects as a player would.
 +
 +
===Inspector===
 +
Lets you see relevant information about whatever you have selected, be it a Game Object, script, Material, model, etc.
 +
 +
===Hierarchy===
 +
A textual list of all the objects in the scene, which also lets you see how each object is connected.
 +
 +
===Project===
 +
Shows all the non-hidden files in your project's Assets folder, located at the memory address you chose when you created the project.
 +
 +
===Asset Store===
 +
You will mostly learn about the asset store when it is mentioned in relation to manipulating and importing objects, but this is really useful if you aren't able to make every single asset yourself, or just want something to test with temporarily.
  
= overview of editor and various tabs =
+
===Console===
There's a lot of UI here whose functionality may or may not seem obvious to you, so I will try to explain what each piece is for.
+
This is where debug messages, warnings, and errors in the code will inevitably be shown with some relevant details.
  
 +
There are four buttons on the left that help organize this tab:
 +
* Clear: Deletes all the messages in the log.
 +
* Collapse: Displays only a single message, collapsing all identical messages. A number, to the left of the message, increases by one when the same message appears again.  This can make the console easier to read but doesn't necessarily keep the order in which the messages happened.
 +
* Clear on Play: The console log gets cleared once play is pressed, so the messages from previous tests are not shown.
 +
* Error Pause: If an error appears after play is pressed, it will pause the game so that no further errors are generated, allowing the developer to identify the issues.
  
= placing things in a scene =
+
The buttons on the right filter between debug messages, warnings, and errors.
  
==primitive 3d objects==
+
= Placing objects in a scene =
2 ways to place primitive 3d shapes in a scene:
+
 
Right-click in the Hierarchy tab,
+
==Primitive 3D objects==
 +
There are two ways to place primitive 3D shapes in a scene:
 +
 
 +
1. Right-click in the Hierarchy tab.
 +
 
 +
2. Select "GameObject" at the top of the screen.
 +
 
 +
(The first way is shown below)
  
 
[[File:placeCube.png|200px]]  
 
[[File:placeCube.png|200px]]  
  
Two things happen: one, a cube is added to the lists of objects in the hierarchy tab, and two, you should now see a cube in the Scene tab/viewer:
+
The second step for both methods stated above: go to 3D Object and choose the shape you want.
 +
 
 +
If cube is selected, two things happen:  
 +
 
 +
1. A cube is added to the lists of objects in the hierarchy tab  
 +
 
 +
2. There is a cube in the Scene tab/viewer.
  
[[File:cubeInHierarchy.png]] [[File:cubeInScene.png]]
+
[[File:cubeInHierarchy.png]] [[File:cubeInScene.png|500px]]
  
and if the cube has an orange outline, as shown in my scene tab, there should also be some new information in the Inspector tab:
+
If the cube has an orange outline, as shown in the scene tab, it is selected, and information about the cube is displayed in the Inspector tab.
  
 
[[File:cubeInInspector.png]]
 
[[File:cubeInInspector.png]]
  
 +
Manipulating objects in the Inspector tab is very important, for example, it allows you to move, rotate, or scale the object in a precise manner. Objects can also be manipulated in the Scene tab by adjusting the red, green, or blue axes.
 +
 +
Some tips and shortcuts for object manipulation in Scene view:
 +
* W brings up the handles for positioning, E is for rotation, and R is for scaling.
 +
* T will display a square with a small circle in the middle which lets you move the object around wherever the mouse is, and you can also scale from corners or sides of the object individually. This is instead of scaling from the center point of the object on the axis you're working with, which is how it usually works.
 +
* Q just lets you move around the scene in the view, which can be very useful.
 +
* F focuses in on whatever object you have selected.
 +
* ctrl-D duplicates the selected object.
 +
* Right-clicking and moving the mouse allows you to rotate your view in the scene.  Ctrl middle-click allows translation of the camera position.
 +
 +
==Lights==
 +
 +
To add a light to a scene, you would go to GameObject > Light and select one of the following kinds of lights to add:
 +
 +
'''Spotlight''': Exactly like it sounds, it's a cone of light for which you can specify the spot angle, range, intensity, and color.  There are of course other setting you can see in the inspector but those 4 are the most important.  All of these can be adjusted based on variables with scripting.  Light doesn't really go past the given range, even when you might feel like it should.  Spot angle corresponds to how wide you want the cone of light to be. Intensity is a range of how bright the light is, 0 being that it emits no light, and 1 being the brightest it can possibly be.
 +
 +
'''Point light''': Very similar to the spotlight except that instead of the light brightening an area in a cone shape, point lights are a sphere of light going from the center of the object to the specified radius in every direction.
 +
 +
'''Directional light''': typically used for lights that affect an entire scene, like a sun or moon.  There is no range for this type of light because it's meant to be global.  If you want shadows, pick Shadow Type > Soft Shadows (or Hard Shadows, try them both and decide which on is better for your project).  You usually only want to have 1, or 2 if you want something like a day/ night cycle, of these in a scene.
 +
 +
'''Area light''': This one is not used nearly as often as the 3 above, but for lighting rooms evenly this can be an extremely useful tool.
 +
 +
[https://docs.unity3d.com/Manual/Lighting.html A more thorough explanation of lighting in Unity.]
 +
 +
==Models from your project assets==
 +
 +
===Asset Store===
 +
If you don't already have any assets you want to use and aren't good at 3d modeling, or just want a base asset to edit, I'd highly suggest looking in the Asset Store (you can get to it by going to Window > Asset Store).  It has a huge variety of useful scripts, 3d models, audio clips, textures, and shaders, many of which are free.  Some assets do cost money, so be mindful of this, read the reviews, look at how frequently it gets been updated, and if it is okay with the your version of Unity.  If you do decide to buy an asset, it will be available for any project you decide to do with Unity, and can be imported to other programs too, if you want.
 +
 +
[[File:assetStore.png|500px]]
 +
 +
Once you've selected an asset, you can download it from the store window, and then Unity will ask you what parts you'd like to import, it defaults to all but you can deselect folders or specific items from the package. 
 +
 +
[[File:importPackage.png|300px]]
 +
 +
If you have a model you'd like to import into Unity without the Asset Store, the easiest way to do so is to just drag it from your file manager into the Project tab, which is by default placed below the Hierarchy and Scene + Game tabs.
 +
Once you have a model of the right format (see [https://docs.unity3d.com/Manual/3D-formats.html here] for a list of Unity compatible file types) find it in the Project tab, and drag it into the Scene or into the Hierarchy.  Make sure you know the difference between Scene view and Game view! You can only change things in Scene view, but the Game tab allows you to test how the game actually plays.  I will be talking about both of these more later in this guide.
 +
 +
==Parent/child hierarchy==
 +
[[File:hierarchy.png]]
 +
 +
To make an object the child of another, all one has to do is drag the chosen child object in the Hierarchy to the name of the chosen parent object (again in  the Hierarchy, this is the only place other than in scripting, that this can be done).  Now you might be asking what the point of a parent child object relationship, and aside from organization purposes, child objects keep their position, rotation, and scale in relation to their parent object.  So when you move around a parent, the child stays in its relative position from the parent object.  See how, in the image below, even if I only have Plane selected in the hierarchy, it looks like both the plane and the sphere are selected in scene view?
 +
 +
[[File:parentChild.png]]
 +
 +
This is called local positioning.  When an object has no parent it still has a local position, but it is the same as its global position, because every object is a child of the scene or world itself.  This becomes important later because you may want to change an object's relative position to a parent and not the global, or maybe you want to edit both, but just make sure you know the difference between an object's local, or relative position and global position.  If an object is a child object, the Transform (meaning the position, rotation, and scale) is relative, or local, to the parent object.  The same goes for rotation and scale, although you usually only want to change local scale, changing an object's global scale is never a great idea.
 +
 +
= How to test things out =
 +
If you don't already have a folder labeled 'Standard Assets' in your project tab, or if you look in that folder but don't see the 'Characters' folder, then in your project tab right-click and go to 'Import Package' > 'Characters'.
 +
 +
In the Characters folder (in Standard Assets), go to FirstPersonCharacter > Prefabs and drag RigidBodyFPSController from that folder into the scene somewhere on top of a plane or a cube, or any object you already have in the scene.  When you press play in the next step you will be able to see the world from the point of view of that Controller, and even walk and jump around using W,A,S,D and  the Space Bar respectively.  You can also change the position in which the player starts the game by moving this controller around in the scene.
 +
 +
[[File:fpsController.png]]
 +
 +
The camera icon seen in the image above represents what you, or the player, sees.  The gray lines extending from that camera show the angles of where the player can see and how far away they can see things.  Those can also be adjusted if you find the child object of the controller (if an object has any children they can be seen in the hierarchy by pressing the triangle next to the parent name) called Main Camera. Then make adjustments to Field of View or Clipping Planes (for changing maximum view distance).  There are plenty more options to explore in there t
  
==lights==
+
[[File:playButton.png]]
 +
That play button allows you to test everything you've made so far! 
  
* spot light
+
If Scene and Game are in the same window space, as above, Unity will automatically switch you from Scene to Game.  You are still able to edit everything you were able to while not in play mode, so I usually keep Scene and Game in separate areas next to each other to more easily test things.  You can drag the tabs/ windows wherever you want by picking them up by their title.  To leave this mode to return to editing, click the, now blue, play button.  If you can't see your mouse, that's probably fine, just press ESC and it will appear.
  
* point light
+
If you walk your controller off of the platforms you've created, you will fall infinitely into the void, and if you do that my suggestion is just to leave play mode and try again.
  
* area light
+
[[File:Game+Scene.png|450px]]
  
* directional light
+
==Play versus edit mode==
 +
Any changes you make to the world or its objects while in play mode will not get saved! Please keep this in mind.  One way around that that I've found is to copy the edited object while in play mode and once you've gone back to edit, you can paste the edited version in and delete the original.  As an alternative you can also copy individual aspects of an object (such as the Transform which contains position, rotation, and scale) by finding the relevant part in the Inspector, and clicking the little gear at the top right of every part, which are otherwise known as Components.
  
==models from your project assets==
+
[[File:copyComponent.png]]
  
==parent/ child hierarchy==
+
'''Note''': Changes to scripts are not affected by this limitation, but if you change a script while in play and save it, Unity will reload '''all''' its scripts, not just the one you edited, and this may break things, especially things that should only happen when the game first starts up.
  
= how to test things out =
+
[http://space.apps.uri.edu/wiki/index.php?title=Materials '''Onto the next part?''']
==play vs edit mode==
 

Latest revision as of 17:04, 14 February 2018

Main guide page

Please Note: This page is a work in progress and may not be 100% correct or complete. If there are any questions or clarifications is needed, please ask! Questions are welcome and will help make this guide better. There is no need for coding knowledge to do any of the things listed in this part of the guide.


Downloading Unity

The personal edition of Unity is capable of meeting any needs one may have for practice and or enjoyment, it’s free and is the version recommended for beginners. Unity policies states that if a developer earns an x-amount of money, they are required to purchase one of the non-personal editions. The non-personal editions offer a better server for multiplayer games, cloud support, etc.

Once Unity is downloaded, start the Download Assistant and accept the licence (choose the 64-bit version). For the components to include, it is recommended to have Unity, Standard Assets, and Build Support for whatever system(s) being used for game play/use.

Starting a new world

Open Unity and sign in to start, then click on 'New' (To make a Unity account go to https://unity3d.com).

UnityNewScene.png

Name the project in the Project Name field, and pick a save location for the project. This tutorial is for making a 3D game, so select that option, if it isn't already selected. Do not worry about Asset Packages or Unity Analytics yet. Select 'Create project'. After everything loads, a popup may appear asking to update Unity. (If so, accept.)

Once any updates are complete the screen should look like this:


UnityDefaultLayout.png

Manipulation of the Camera

To pan the camera hold down middle mouse click and move the mouse around. You can also rotate the camera by holding down the Alt key and moving the mouse around.

Overview of editor and various tabs

The following is a list of all the UI tabs you might have to deal with:

UiWindows.png

This guide is going to talk about the most important tabs, but feel free to look up the others and explore.

Scene

This is where everything that the player sees in the game can be edited, like objects' positioning, rotation, and scaling.

Game

The view that lets you test out gameplay. It shows the initial view of the main camera. It is almost useless until you press play, at which point you will be able to move around the world and interact with objects as a player would.

Inspector

Lets you see relevant information about whatever you have selected, be it a Game Object, script, Material, model, etc.

Hierarchy

A textual list of all the objects in the scene, which also lets you see how each object is connected.

Project

Shows all the non-hidden files in your project's Assets folder, located at the memory address you chose when you created the project.

Asset Store

You will mostly learn about the asset store when it is mentioned in relation to manipulating and importing objects, but this is really useful if you aren't able to make every single asset yourself, or just want something to test with temporarily.

Console

This is where debug messages, warnings, and errors in the code will inevitably be shown with some relevant details.

There are four buttons on the left that help organize this tab:

  • Clear: Deletes all the messages in the log.
  • Collapse: Displays only a single message, collapsing all identical messages. A number, to the left of the message, increases by one when the same message appears again. This can make the console easier to read but doesn't necessarily keep the order in which the messages happened.
  • Clear on Play: The console log gets cleared once play is pressed, so the messages from previous tests are not shown.
  • Error Pause: If an error appears after play is pressed, it will pause the game so that no further errors are generated, allowing the developer to identify the issues.

The buttons on the right filter between debug messages, warnings, and errors.

Placing objects in a scene

Primitive 3D objects

There are two ways to place primitive 3D shapes in a scene:

1. Right-click in the Hierarchy tab.

2. Select "GameObject" at the top of the screen.

(The first way is shown below)

PlaceCube.png

The second step for both methods stated above: go to 3D Object and choose the shape you want.

If cube is selected, two things happen:

1. A cube is added to the lists of objects in the hierarchy tab

2. There is a cube in the Scene tab/viewer.

CubeInHierarchy.png CubeInScene.png

If the cube has an orange outline, as shown in the scene tab, it is selected, and information about the cube is displayed in the Inspector tab.

CubeInInspector.png

Manipulating objects in the Inspector tab is very important, for example, it allows you to move, rotate, or scale the object in a precise manner. Objects can also be manipulated in the Scene tab by adjusting the red, green, or blue axes.

Some tips and shortcuts for object manipulation in Scene view:

  • W brings up the handles for positioning, E is for rotation, and R is for scaling.
  • T will display a square with a small circle in the middle which lets you move the object around wherever the mouse is, and you can also scale from corners or sides of the object individually. This is instead of scaling from the center point of the object on the axis you're working with, which is how it usually works.
  • Q just lets you move around the scene in the view, which can be very useful.
  • F focuses in on whatever object you have selected.
  • ctrl-D duplicates the selected object.
  • Right-clicking and moving the mouse allows you to rotate your view in the scene. Ctrl middle-click allows translation of the camera position.

Lights

To add a light to a scene, you would go to GameObject > Light and select one of the following kinds of lights to add:

Spotlight: Exactly like it sounds, it's a cone of light for which you can specify the spot angle, range, intensity, and color. There are of course other setting you can see in the inspector but those 4 are the most important. All of these can be adjusted based on variables with scripting. Light doesn't really go past the given range, even when you might feel like it should. Spot angle corresponds to how wide you want the cone of light to be. Intensity is a range of how bright the light is, 0 being that it emits no light, and 1 being the brightest it can possibly be.

Point light: Very similar to the spotlight except that instead of the light brightening an area in a cone shape, point lights are a sphere of light going from the center of the object to the specified radius in every direction.

Directional light: typically used for lights that affect an entire scene, like a sun or moon. There is no range for this type of light because it's meant to be global. If you want shadows, pick Shadow Type > Soft Shadows (or Hard Shadows, try them both and decide which on is better for your project). You usually only want to have 1, or 2 if you want something like a day/ night cycle, of these in a scene.

Area light: This one is not used nearly as often as the 3 above, but for lighting rooms evenly this can be an extremely useful tool.

A more thorough explanation of lighting in Unity.

Models from your project assets

Asset Store

If you don't already have any assets you want to use and aren't good at 3d modeling, or just want a base asset to edit, I'd highly suggest looking in the Asset Store (you can get to it by going to Window > Asset Store). It has a huge variety of useful scripts, 3d models, audio clips, textures, and shaders, many of which are free. Some assets do cost money, so be mindful of this, read the reviews, look at how frequently it gets been updated, and if it is okay with the your version of Unity. If you do decide to buy an asset, it will be available for any project you decide to do with Unity, and can be imported to other programs too, if you want.

AssetStore.png

Once you've selected an asset, you can download it from the store window, and then Unity will ask you what parts you'd like to import, it defaults to all but you can deselect folders or specific items from the package.

ImportPackage.png

If you have a model you'd like to import into Unity without the Asset Store, the easiest way to do so is to just drag it from your file manager into the Project tab, which is by default placed below the Hierarchy and Scene + Game tabs. Once you have a model of the right format (see here for a list of Unity compatible file types) find it in the Project tab, and drag it into the Scene or into the Hierarchy. Make sure you know the difference between Scene view and Game view! You can only change things in Scene view, but the Game tab allows you to test how the game actually plays. I will be talking about both of these more later in this guide.

Parent/child hierarchy

Hierarchy.png

To make an object the child of another, all one has to do is drag the chosen child object in the Hierarchy to the name of the chosen parent object (again in the Hierarchy, this is the only place other than in scripting, that this can be done). Now you might be asking what the point of a parent child object relationship, and aside from organization purposes, child objects keep their position, rotation, and scale in relation to their parent object. So when you move around a parent, the child stays in its relative position from the parent object. See how, in the image below, even if I only have Plane selected in the hierarchy, it looks like both the plane and the sphere are selected in scene view?

ParentChild.png

This is called local positioning. When an object has no parent it still has a local position, but it is the same as its global position, because every object is a child of the scene or world itself. This becomes important later because you may want to change an object's relative position to a parent and not the global, or maybe you want to edit both, but just make sure you know the difference between an object's local, or relative position and global position. If an object is a child object, the Transform (meaning the position, rotation, and scale) is relative, or local, to the parent object. The same goes for rotation and scale, although you usually only want to change local scale, changing an object's global scale is never a great idea.

How to test things out

If you don't already have a folder labeled 'Standard Assets' in your project tab, or if you look in that folder but don't see the 'Characters' folder, then in your project tab right-click and go to 'Import Package' > 'Characters'.

In the Characters folder (in Standard Assets), go to FirstPersonCharacter > Prefabs and drag RigidBodyFPSController from that folder into the scene somewhere on top of a plane or a cube, or any object you already have in the scene. When you press play in the next step you will be able to see the world from the point of view of that Controller, and even walk and jump around using W,A,S,D and the Space Bar respectively. You can also change the position in which the player starts the game by moving this controller around in the scene.

FpsController.png

The camera icon seen in the image above represents what you, or the player, sees. The gray lines extending from that camera show the angles of where the player can see and how far away they can see things. Those can also be adjusted if you find the child object of the controller (if an object has any children they can be seen in the hierarchy by pressing the triangle next to the parent name) called Main Camera. Then make adjustments to Field of View or Clipping Planes (for changing maximum view distance). There are plenty more options to explore in there t

PlayButton.png That play button allows you to test everything you've made so far!

If Scene and Game are in the same window space, as above, Unity will automatically switch you from Scene to Game. You are still able to edit everything you were able to while not in play mode, so I usually keep Scene and Game in separate areas next to each other to more easily test things. You can drag the tabs/ windows wherever you want by picking them up by their title. To leave this mode to return to editing, click the, now blue, play button. If you can't see your mouse, that's probably fine, just press ESC and it will appear.

If you walk your controller off of the platforms you've created, you will fall infinitely into the void, and if you do that my suggestion is just to leave play mode and try again.

Game+Scene.png

Play versus edit mode

Any changes you make to the world or its objects while in play mode will not get saved! Please keep this in mind. One way around that that I've found is to copy the edited object while in play mode and once you've gone back to edit, you can paste the edited version in and delete the original. As an alternative you can also copy individual aspects of an object (such as the Transform which contains position, rotation, and scale) by finding the relevant part in the Inspector, and clicking the little gear at the top right of every part, which are otherwise known as Components.

CopyComponent.png

Note: Changes to scripts are not affected by this limitation, but if you change a script while in play and save it, Unity will reload all its scripts, not just the one you edited, and this may break things, especially things that should only happen when the game first starts up.

Onto the next part?