Skip to content
mbaranowski edited this page Jan 11, 2013 · 3 revisions

Unity3D Tutorial Notes

Starting off

Overview of the Interface

  • Project View
    • where you access and manage the file assets that make up your project
    • assets are the building blocks of your game scenes, one asset can be reused by many game objects
    • corresponds to the folder and file hierarchy used by your project
    • automatically updates when changes are detected on disk
    • Assets: Meshes, Textures, Materials, Shaders, Scenes
    • Scenes are assets, at anytime one scene is open in the editor
    • open menu in the Upper-right hand corner to select between one or two column layout. For small projects one column layout is easier to use.
    • In two column layout, bottom right of the window has a icon size slider.
  • Hierarchy View
    • Shows the scene graph of game objects, building blocks of a scene
      • games made from one or more scenes, just a collection of game objects. *a scene must have at least one camera
    • Use Top toolbar to add some pre-defined objects to the scene, like a cube.
    • Select an object and press enter to change name
    • Drag one object on top of another to make it the child
    • Selecting one highlights it in the scene view and shows its details in the inspector
    • Make at least two cubes and make it so one cube has at least one child.
  • Scene View
    • Select object in hierarchy view, then with the mouse over the scene view press (F) to zoom in on that object.
    • find manipulation toolbar in Top-Left of the editor window
      • (Q) Hand allows you to pan around the scene
      • (W) Move Tool allows you to move selected objects
      • (E) Rotate Tool allows you to rotate selected objects
      • (R) Scale Tool allows you to scale
    • Basic scene view camera controls
      • Top-right corner has the scene gizmo that helps choose viewing direction
      • Click on center box switches between orthographic (2D) and perspective (3D) views.
      • Hold Alt and click-drag to orbit the camera around the current pivot point.
      • Select an item by left click (or in hierarchy view)
      • press F to zoom in and make it the current pivot point.
      • scroll gesture to zoom in out
  • Inspector View
    • Shows the details of the currently selected objects
    • Shows that each GameObject is composed of one or more Components
    • Every GameObject has a transform Transform to set location/scale/position
    • There are many built-in engine Components that make a game object do something interesting.
    • Top-Right there is book icon button that brings up documentation on each component
  • Game View
    • Press Play to run the current scene in the game view
    • Any changes done to the scene objects are reset after the game is finished playing
    • iPhone Remote can be used to send touch events to editor
    • At this point there might be nothing in the game view.
  • Other Views
    • Asset Store
    • Console
    • Animation, Particle etc.

Tutorial Project Overview

  • Hierarchy View

    • AimTarget - red sphere controlled by the mouse that the player uses to aim
    • Directional Light - the sun provides some light so its not all dark grey (from the ambient light)
    • Main Camera - the main camera the player looks through, uses LookAt script to always point at the center of the floor cube.
    • Player - the root of the player game object hierarchy. Contains the Player.cs script that moves the player based on input, fires bullets, handles collision and death animations.
      • LBP - Empty game object that is the root of the two-part player model.
        • Head - the Player.cs script (above) points the head to always look at AimTarget
        • Legs - the body of the player
    • World - contains the Spawner script that spawns enemies. It is also the parent of all the static cubes that provide the solid world for the player to stand on.
  • Assets - quick overview of scripts

    • AimTarget.cs - each frame, performs a ray cast against the world to find the position where a ray originating from the mouse cursor hits the 3d world. It then sets the transform of the game object to that position. The result is that the game object always follows the mouse cursor above it, following the game world, unless the cursor is over empty space.
    • Enemy.cs - Implement the simple AI of the enemy. Every frame the enemy tries to move in a straight line from its current position to the player. It also handles collision events. If it gets hit by a bullet it destroys itself.
    • LookAt.cs - in the Update function (called) every frame, point at the target. This is used to orient the camera, but could be used for anything else.
    • MoveMotor.cs - a utility script that move a game object with a rigidbody component based on two publcic vector parameters: movementDirection and facing direction.
    • Player -
    • Spawner -
    • Utility

Clone this wiki locally