SlideShare uma empresa Scribd logo
1 de 47
Baixar para ler offline
Introduction to Unity
For Unity 3.5




Petri Lankoski, petri.lankoski@sh.se
New Project
     File -> New Project…

     Set name and directory
      where you want to store the
      project

     Select
        Image Effect (ONLY IF
         YOU HAVE Pro)
        Toon Shading




Petri Lankoski, petri.lankoski@sh.se
Importing a Package
     Download:
        If you have free version:
            http://www.mediafire.com/file/2bdmrn5j4vcikpa/
             escape_stripped.unitypackage.zip
        If you have Pro
            http://www.mediafire.com/file/y5i38txo42fj8i3/esc
             ape.unitypackage.zip
        Unzip the downloaded file

     Assets -> Import Package -> Custom Package…
        Select the downloaded package


Petri Lankoski, petri.lankoski@sh.se
Anatomy of Unity GUI
 Project Frame contains assets
 and scripts
 • We got these from packages
 • These are your tools to build
    the game




Petri Lankoski, petri.lankoski@sh.se
Anatomy of Unity GUI
                                       Scene & Hierarchy views
                                       • View to your level (game)
                                       • For building a level




Petri Lankoski, petri.lankoski@sh.se
Building a scene


         Delete Main Camera




Petri Lankoski, petri.lankoski@sh.se
Adding a Plain




Petri Lankoski, petri.lankoski@sh.se
Anatomy of Unity GUI

Inspector
• Shows details of the
   selected object




Petri Lankoski, petri.lankoski@sh.se
Modifying the Plain
                                                         Change X and
                                       These should be   Z to 20
                                       0                 • Experiment
                                                            to find
                                                            suitable
                                                            scale
                                                         • Y should be
            Drag-and-drop                                   1
            ground to plain




Petri Lankoski, petri.lankoski@sh.se
Navigating in Unity
Move tool (shortcut: W)

                                              Play Mode
                Rotate tool (shortcut: E)




                  Scale tool (shortcut: R)

    Hand tool (shortcut: Q)                  On scene view:
    - click-drag to move camera              • F to zoom to selected
    - ALT click-drag to orbit                object
    camera around                            • Hold right mouse to enable
    - CTR click-drag to zoom                      • ASWD movement
Petri Lankoski, petri.lankoski@sh.se              • Q up, E down
Save a Scene
     File -> Save Scene
        Name it “First”
            Or something else




Petri Lankoski, petri.lankoski@sh.se
Player & Light Source




       Drag-and-drop
       Player




Petri Lankoski, petri.lankoski@sh.se
Directional Light



  Move by                              Rotate by
  Drag from                            Drag from
  An arrow                             The sphere




Petri Lankoski, petri.lankoski@sh.se
Player Prefab
                                       Make sure
                                       that
                                       Object is on
                                       the plain
                                       • Set to 0,0,0


                                       Drag up until
                                       the object is
                                       totally visible




Petri Lankoski, petri.lankoski@sh.se
Adding Manager
                                        Rename the empty object
                                         as GameManager




                                        Drag-and-drop
                                         GameAgents on
                                         GameManager




Petri Lankoski, petri.lankoski@sh.se
Time to Test
                                       Hit Play




Petri Lankoski, petri.lankoski@sh.se
Adding Waypoints for an
    Enemy

                                       Drag and drop
                                       four Waypoint to
                                       scene
                                       • Place them to
                                         corners (as in
                                         Figure)
                                       • Make sure
                                         that
                                         Waypoints are
                                         on top of the
                                         plain


Petri Lankoski, petri.lankoski@sh.se
Grouping Objects in Hierarchy



             Rename waypoints          Grouping Object




Petri Lankoski, petri.lankoski@sh.se
Connecting Waypoints

                                       1. Drag and
                                          drop
                                          Waypoint2 to
                                          NextTarget on
                                          Waypoint1
                                       2. Drag and
                                          drop
                                          Waypoint3 to
                                          NextTarget on
                                          Waypoint2
                                       3. …


Petri Lankoski, petri.lankoski@sh.se
Connecting Waypoints




                Drag-and-
                drop Enemy




Petri Lankoski, petri.lankoski@sh.se
Adding an Enemy




           Drag-and-drop
           Waypoint1 Target (on
           Enemy)




Petri Lankoski, petri.lankoski@sh.se
Time to Test




Petri Lankoski, petri.lankoski@sh.se
Adding Things
     Walls:
        Hierarchy: Create ->
         Cube
        Scale & Rotate & Move

     More complex objects are
      modeled in separate
      software.




Petri Lankoski, petri.lankoski@sh.se
New Objects from Maya
     Create an object in Maya
        Save (ma/mb)
            Maya needed on the machine running Unity
        Export FBX

     Move the model to Assets folder

     Set import scale
        Do not use Transform – Scale on Inspector with
         imported models to change the default scale




Petri Lankoski, petri.lankoski@sh.se
New Textures
     Create a texture in Photoshop
        Preferred size: n2 x m2
        Default max size of a texture: 1024x1024
            Bigger textures consumes more memory
        Use psd or tiff formata
            Keep layers

     Save it to Assets folder

     Open Unity



Petri Lankoski, petri.lankoski@sh.se
Renderer & Materials
     An object has renderer
        Renderer draws the object to the screen
        Renderer has one or materials

     Materials consists of
        Shader
        Resources that the shader needs for rendering
            E.g., textures, colors, other assets

     Multiple objects can share a material
        If the material is changed, the rendering of all
         objects having that material is changed.

Petri Lankoski, petri.lankoski@sh.se
Material
                                       Shader



                                       This part
                                       changes
                                       based on the
                                       selected
                                       shader



                                       Preview


Petri Lankoski, petri.lankoski@sh.se
Prefabs
                                       In Escape Package




Petri Lankoski, petri.lankoski@sh.se
Checkbox for
                                       Enabling/disabling
    Enemy                              scripts


                                                            Collider
                                                            • For moving
                                                              objects


                                                            Plays sounds


                                                            Enemy logic
                                                            • Movement
                                                              speed
                                                            • Damage
                                                              dealt
                                                            • Sound files

Petri Lankoski, petri.lankoski@sh.se
Colliders & Collision

                                          STATIC




                                 STATIC

                                                   STATIC




Petri Lankoski, petri.lankoski@sh.se
Colliders & Collision

                                          STATIC




                                 STATIC

                                                   STATIC




Petri Lankoski, petri.lankoski@sh.se
Enemy



                                       Fine-tune how this
                                       enemy perceives




Petri Lankoski, petri.lankoski@sh.se
Enemy

                                       Tag is used with
                                       waypoints
                                       • Different tags
                                         ensure that
                                         enemies keep
                                         their tracks




Petri Lankoski, petri.lankoski@sh.se
Enemy Components /
    Billboard

                                       Enemy consists
                                       of multiple
                                       billboards
                                       • Texture
                                           animation
                                       • Textures
                                       • Animations
                                           speed




Petri Lankoski, petri.lankoski@sh.se
Enemy Components / Light




Petri Lankoski, petri.lankoski@sh.se
Waypoints

                                       This should match
                                       to Tag of an
                                       enemy
                                       • Default ok if
                                          you do not
                                          have crossing
                                          tracks


                                       Waypoint has a
                                       collider
                                       • Place it so that
                                         an enemy can
Petri Lankoski, petri.lankoski@sh.se     collide with it
Door


                                       Player reached
                                       the end if this is
                                       checked


                                       These controls
                                       how
                                       completing the
                                       game is shown


Petri Lankoski, petri.lankoski@sh.se
Door

                                       The name of level
                                       where the door
                                       leads
                                       • If multiple
                                          names are
Levels needs to be                        provided, one
in Scenes in Build!                       is selected
                                          randomly




Petri Lankoski, petri.lankoski@sh.se
Door with Lock




Petri Lankoski, petri.lankoski@sh.se
Player Start Waypoint
     Player object only to the first
      level

     In levels 1-
        Place PlayerStart where
         the player object begins




Petri Lankoski, petri.lankoski@sh.se
Scenes (levels)
     Level 0
        Splash screen
        Very minimal to

     Levels 1+
        Actual game levels




Petri Lankoski, petri.lankoski@sh.se
Setting up Start Screen
     File -> New Scene
     Download package:
        http://dl.dropbox.com/u/1380179/escape_mainmen
         u.unitypackage

     Assets -> Import Package -> Custom Package…
        Select escape_mainmenu.unitypackage

     Add Player prefab to scene
        This is the only level where Player should be!
        You can add the Player for testing
          Remove after level is ready


Petri Lankoski, petri.lankoski@sh.se
Escape Splash Screen


                                 Drag-and-drop




                                                 Draws the GUI



Petri Lankoski, petri.lankoski@sh.se
Setting up Start Screen


                                       Write the
                                       name of
                                       your first
                                       level




Petri Lankoski, petri.lankoski@sh.se
GUI Skin

                                       Changes how
                                       buttons and
                                       labels look like




Petri Lankoski, petri.lankoski@sh.se
Start Screen




Petri Lankoski, petri.lankoski@sh.se
Build Game

                                       Select:
                                       • File -> Build Settings…




                                       Select target and build




                                       Alternatively:
                                       • File -> Build Settings…

Petri Lankoski, petri.lankoski@sh.se

Mais conteúdo relacionado

Mais de Petri Lankoski

Game research methods book introduction
Game research methods book introductionGame research methods book introduction
Game research methods book introductionPetri Lankoski
 
Escape: Level Design Exercise in Unity
Escape: Level Design Exercise in UnityEscape: Level Design Exercise in Unity
Escape: Level Design Exercise in UnityPetri Lankoski
 
Formal analysis of gameplay
Formal analysis of gameplayFormal analysis of gameplay
Formal analysis of gameplayPetri Lankoski
 
Simulations: Evaluating game system behavior
Simulations: Evaluating game system behavior Simulations: Evaluating game system behavior
Simulations: Evaluating game system behavior Petri Lankoski
 
Designprocesser lecture1
Designprocesser lecture1Designprocesser lecture1
Designprocesser lecture1Petri Lankoski
 
Gameplay Design Workshop 1/2 (2011)
Gameplay Design Workshop 1/2 (2011)Gameplay Design Workshop 1/2 (2011)
Gameplay Design Workshop 1/2 (2011)Petri Lankoski
 
Gameplay Design Workshop 2/2 (2011)
Gameplay Design Workshop 2/2 (2011)Gameplay Design Workshop 2/2 (2011)
Gameplay Design Workshop 2/2 (2011)Petri Lankoski
 
How can game studies support game design practice?
How can game studies support game design practice?How can game studies support game design practice?
How can game studies support game design practice?Petri Lankoski
 
Game Project / Assignement
Game Project / AssignementGame Project / Assignement
Game Project / AssignementPetri Lankoski
 
Game Project / Working with Unity
Game Project / Working with UnityGame Project / Working with Unity
Game Project / Working with UnityPetri Lankoski
 
Game Analysis, lecture 1
Game Analysis, lecture 1Game Analysis, lecture 1
Game Analysis, lecture 1Petri Lankoski
 
Game Design, Lecture1: Design
Game Design, Lecture1: DesignGame Design, Lecture1: Design
Game Design, Lecture1: DesignPetri Lankoski
 
Gameplay Design Workshop 2/3
Gameplay Design Workshop 2/3Gameplay Design Workshop 2/3
Gameplay Design Workshop 2/3Petri Lankoski
 
Gameplay Design Workshop 1/3
Gameplay Design Workshop 1/3Gameplay Design Workshop 1/3
Gameplay Design Workshop 1/3Petri Lankoski
 
Game Design and Procution: Introduction to Studies
Game Design and Procution: Introduction to StudiesGame Design and Procution: Introduction to Studies
Game Design and Procution: Introduction to StudiesPetri Lankoski
 

Mais de Petri Lankoski (19)

Game research methods book introduction
Game research methods book introductionGame research methods book introduction
Game research methods book introduction
 
Escape: Level Design Exercise in Unity
Escape: Level Design Exercise in UnityEscape: Level Design Exercise in Unity
Escape: Level Design Exercise in Unity
 
Formal analysis of gameplay
Formal analysis of gameplayFormal analysis of gameplay
Formal analysis of gameplay
 
Game system design
Game system designGame system design
Game system design
 
Simulations: Evaluating game system behavior
Simulations: Evaluating game system behavior Simulations: Evaluating game system behavior
Simulations: Evaluating game system behavior
 
Models for story
Models for storyModels for story
Models for story
 
Designprocesser lecture1
Designprocesser lecture1Designprocesser lecture1
Designprocesser lecture1
 
Unity programming 1
Unity programming 1Unity programming 1
Unity programming 1
 
Gameplay Design Workshop 1/2 (2011)
Gameplay Design Workshop 1/2 (2011)Gameplay Design Workshop 1/2 (2011)
Gameplay Design Workshop 1/2 (2011)
 
Gameplay Design Workshop 2/2 (2011)
Gameplay Design Workshop 2/2 (2011)Gameplay Design Workshop 2/2 (2011)
Gameplay Design Workshop 2/2 (2011)
 
How can game studies support game design practice?
How can game studies support game design practice?How can game studies support game design practice?
How can game studies support game design practice?
 
Game Project / Focus
Game Project / FocusGame Project / Focus
Game Project / Focus
 
Game Project / Assignement
Game Project / AssignementGame Project / Assignement
Game Project / Assignement
 
Game Project / Working with Unity
Game Project / Working with UnityGame Project / Working with Unity
Game Project / Working with Unity
 
Game Analysis, lecture 1
Game Analysis, lecture 1Game Analysis, lecture 1
Game Analysis, lecture 1
 
Game Design, Lecture1: Design
Game Design, Lecture1: DesignGame Design, Lecture1: Design
Game Design, Lecture1: Design
 
Gameplay Design Workshop 2/3
Gameplay Design Workshop 2/3Gameplay Design Workshop 2/3
Gameplay Design Workshop 2/3
 
Gameplay Design Workshop 1/3
Gameplay Design Workshop 1/3Gameplay Design Workshop 1/3
Gameplay Design Workshop 1/3
 
Game Design and Procution: Introduction to Studies
Game Design and Procution: Introduction to StudiesGame Design and Procution: Introduction to Studies
Game Design and Procution: Introduction to Studies
 

Introduction to Unity

  • 1. Introduction to Unity For Unity 3.5 Petri Lankoski, petri.lankoski@sh.se
  • 2. New Project  File -> New Project…  Set name and directory where you want to store the project  Select  Image Effect (ONLY IF YOU HAVE Pro)  Toon Shading Petri Lankoski, petri.lankoski@sh.se
  • 3. Importing a Package  Download:  If you have free version:  http://www.mediafire.com/file/2bdmrn5j4vcikpa/ escape_stripped.unitypackage.zip  If you have Pro  http://www.mediafire.com/file/y5i38txo42fj8i3/esc ape.unitypackage.zip  Unzip the downloaded file  Assets -> Import Package -> Custom Package…  Select the downloaded package Petri Lankoski, petri.lankoski@sh.se
  • 4. Anatomy of Unity GUI Project Frame contains assets and scripts • We got these from packages • These are your tools to build the game Petri Lankoski, petri.lankoski@sh.se
  • 5. Anatomy of Unity GUI Scene & Hierarchy views • View to your level (game) • For building a level Petri Lankoski, petri.lankoski@sh.se
  • 6. Building a scene Delete Main Camera Petri Lankoski, petri.lankoski@sh.se
  • 7. Adding a Plain Petri Lankoski, petri.lankoski@sh.se
  • 8. Anatomy of Unity GUI Inspector • Shows details of the selected object Petri Lankoski, petri.lankoski@sh.se
  • 9. Modifying the Plain Change X and These should be Z to 20 0 • Experiment to find suitable scale • Y should be Drag-and-drop 1 ground to plain Petri Lankoski, petri.lankoski@sh.se
  • 10. Navigating in Unity Move tool (shortcut: W) Play Mode Rotate tool (shortcut: E) Scale tool (shortcut: R) Hand tool (shortcut: Q) On scene view: - click-drag to move camera • F to zoom to selected - ALT click-drag to orbit object camera around • Hold right mouse to enable - CTR click-drag to zoom • ASWD movement Petri Lankoski, petri.lankoski@sh.se • Q up, E down
  • 11. Save a Scene  File -> Save Scene  Name it “First”  Or something else Petri Lankoski, petri.lankoski@sh.se
  • 12. Player & Light Source Drag-and-drop Player Petri Lankoski, petri.lankoski@sh.se
  • 13. Directional Light Move by Rotate by Drag from Drag from An arrow The sphere Petri Lankoski, petri.lankoski@sh.se
  • 14. Player Prefab Make sure that Object is on the plain • Set to 0,0,0 Drag up until the object is totally visible Petri Lankoski, petri.lankoski@sh.se
  • 15. Adding Manager  Rename the empty object as GameManager  Drag-and-drop GameAgents on GameManager Petri Lankoski, petri.lankoski@sh.se
  • 16. Time to Test Hit Play Petri Lankoski, petri.lankoski@sh.se
  • 17. Adding Waypoints for an Enemy Drag and drop four Waypoint to scene • Place them to corners (as in Figure) • Make sure that Waypoints are on top of the plain Petri Lankoski, petri.lankoski@sh.se
  • 18. Grouping Objects in Hierarchy Rename waypoints Grouping Object Petri Lankoski, petri.lankoski@sh.se
  • 19. Connecting Waypoints 1. Drag and drop Waypoint2 to NextTarget on Waypoint1 2. Drag and drop Waypoint3 to NextTarget on Waypoint2 3. … Petri Lankoski, petri.lankoski@sh.se
  • 20. Connecting Waypoints Drag-and- drop Enemy Petri Lankoski, petri.lankoski@sh.se
  • 21. Adding an Enemy Drag-and-drop Waypoint1 Target (on Enemy) Petri Lankoski, petri.lankoski@sh.se
  • 22. Time to Test Petri Lankoski, petri.lankoski@sh.se
  • 23. Adding Things  Walls:  Hierarchy: Create -> Cube  Scale & Rotate & Move  More complex objects are modeled in separate software. Petri Lankoski, petri.lankoski@sh.se
  • 24. New Objects from Maya  Create an object in Maya  Save (ma/mb)  Maya needed on the machine running Unity  Export FBX  Move the model to Assets folder  Set import scale  Do not use Transform – Scale on Inspector with imported models to change the default scale Petri Lankoski, petri.lankoski@sh.se
  • 25. New Textures  Create a texture in Photoshop  Preferred size: n2 x m2  Default max size of a texture: 1024x1024  Bigger textures consumes more memory  Use psd or tiff formata  Keep layers  Save it to Assets folder  Open Unity Petri Lankoski, petri.lankoski@sh.se
  • 26. Renderer & Materials  An object has renderer  Renderer draws the object to the screen  Renderer has one or materials  Materials consists of  Shader  Resources that the shader needs for rendering  E.g., textures, colors, other assets  Multiple objects can share a material  If the material is changed, the rendering of all objects having that material is changed. Petri Lankoski, petri.lankoski@sh.se
  • 27. Material Shader This part changes based on the selected shader Preview Petri Lankoski, petri.lankoski@sh.se
  • 28. Prefabs In Escape Package Petri Lankoski, petri.lankoski@sh.se
  • 29. Checkbox for Enabling/disabling Enemy scripts Collider • For moving objects Plays sounds Enemy logic • Movement speed • Damage dealt • Sound files Petri Lankoski, petri.lankoski@sh.se
  • 30. Colliders & Collision STATIC STATIC STATIC Petri Lankoski, petri.lankoski@sh.se
  • 31. Colliders & Collision STATIC STATIC STATIC Petri Lankoski, petri.lankoski@sh.se
  • 32. Enemy Fine-tune how this enemy perceives Petri Lankoski, petri.lankoski@sh.se
  • 33. Enemy Tag is used with waypoints • Different tags ensure that enemies keep their tracks Petri Lankoski, petri.lankoski@sh.se
  • 34. Enemy Components / Billboard Enemy consists of multiple billboards • Texture animation • Textures • Animations speed Petri Lankoski, petri.lankoski@sh.se
  • 35. Enemy Components / Light Petri Lankoski, petri.lankoski@sh.se
  • 36. Waypoints This should match to Tag of an enemy • Default ok if you do not have crossing tracks Waypoint has a collider • Place it so that an enemy can Petri Lankoski, petri.lankoski@sh.se collide with it
  • 37. Door Player reached the end if this is checked These controls how completing the game is shown Petri Lankoski, petri.lankoski@sh.se
  • 38. Door The name of level where the door leads • If multiple names are Levels needs to be provided, one in Scenes in Build! is selected randomly Petri Lankoski, petri.lankoski@sh.se
  • 39. Door with Lock Petri Lankoski, petri.lankoski@sh.se
  • 40. Player Start Waypoint  Player object only to the first level  In levels 1-  Place PlayerStart where the player object begins Petri Lankoski, petri.lankoski@sh.se
  • 41. Scenes (levels)  Level 0  Splash screen  Very minimal to  Levels 1+  Actual game levels Petri Lankoski, petri.lankoski@sh.se
  • 42. Setting up Start Screen  File -> New Scene  Download package:  http://dl.dropbox.com/u/1380179/escape_mainmen u.unitypackage  Assets -> Import Package -> Custom Package…  Select escape_mainmenu.unitypackage  Add Player prefab to scene  This is the only level where Player should be!  You can add the Player for testing  Remove after level is ready Petri Lankoski, petri.lankoski@sh.se
  • 43. Escape Splash Screen Drag-and-drop Draws the GUI Petri Lankoski, petri.lankoski@sh.se
  • 44. Setting up Start Screen Write the name of your first level Petri Lankoski, petri.lankoski@sh.se
  • 45. GUI Skin Changes how buttons and labels look like Petri Lankoski, petri.lankoski@sh.se
  • 46. Start Screen Petri Lankoski, petri.lankoski@sh.se
  • 47. Build Game Select: • File -> Build Settings… Select target and build Alternatively: • File -> Build Settings… Petri Lankoski, petri.lankoski@sh.se