vincent-chau-1259 / UHGameDev-Spring2016

A short tutorial to show off the basics of Game Development and Unity3D

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UH Game Development Tutorial - April 2016

Topics To Cover

  • What is a Game?

    • Extremely hard to define
    • "all games share four defining traits: a goal, rules, a feedback system, and voluntary participation." - Jane McGonigal
  • What is Game Development?

    • Simple Answer: To process to build a game

    • Real Answer: A huge collaborative effort under taken by (potentially many) talented people involving many disciplines to create a polished and fun experience for a player to enjoy

    • Incomplete List of Required Skills in Game Development:

      • Team Management (Producer)
      • Marketing / Distribution (Publisher)
      • Customer Validation (Market Research)
      • Quality Control (Testers)
      • Programming (Programmers)
      • Graphic Design (Artists)
      • Animation (Animators)
      • Textures (Artists)
      • Sound Engineering (Sound Engineers / Musicians)
      • Game Design / Level Design (Designers)
      • Gameplay Testing (Testers / Designers)
  • Game Engines

    • What is a Game Engine?

    A piece of software designed to assist with the creation and development of video games

    • What comes with a Game Engine?

      • The Game Logic
        • Main Game Loop
        • Menus
        • Scripting
        • Object Instantiation / Pooling
        • Garbage Collection
      • Graphics / Rendering
        • Cameras
        • Shaders
        • Textures
        • Materials
        • Lighting
        • Animations
      • Controls
        • Keyboard / Mouse
        • Controllers
        • Networked inputs
      • Audio
        • BGM
        • SFX
        • 3D Audio Effects
      • Physics
        • Colliders / Bounding Boxes
        • Raycasts
        • Physics Materials
        • Gravity
        • Fluid Dynamics
        • Explosions!
      • AI
        • Navigation (Navmeshes)
        • Triggers
        • Areas of Influence
      • Scene Management
        • Level Building
        • Level Loading
        • Scene Serialization
      • VR/AR Support
        • Head-tracking support
        • Motion controls
        • HUD Menus
    • What are some Game Engines?

      • Unity3D
        • Super popular
        • Plenty of tutorials and resources
        • Scripted in C#, JavaScript, or Boo
      • Unreal
        • Super popular
        • Plenty of tutorials and resources
        • Scripted in Blueprints and/or C++
      • CryEngine
        • Highly performant
        • Typically the bleeding edge of technology
        • Scripted in C#, C++, and Lua
      • OGRE
        • Extremely minimal
        • Highly customizable
        • Scripted in C++
  • Case Study: Flappy Bird

    Flappy Bird

    • 2013 Mobile Hit
    • Game Definition
      • Goal
        • Survive as long as possible
        • Get a high score
      • Rules
        • You can't hit the floor
        • You can't hit the pipes
        • You're always falling
      • Feedback System
        • Your inputs direct the bird
        • If directed well, you can get a higher score
      • Voluntary Participation
        • We have a short attention span
        • We get bored easily
  • Unity3D

    • Terminology

      • GameObject

        An object in the game that's governed by a script

      • Transform

        An object that exists within the "world" of the game

      • Component

        An additional piece of functionality that has been added to a game object

    • Interface

      • Hierarchy
        • Parents and Children
      • Scene
        • World Space vs Local Space
      • Game
      • Inspector
        • Layers
        • Tags
        • Transform
        • Components
      • Project
      • Console
      • Controls
        • Scene Management
          • Play
          • Pause
          • Next Frame
        • Hand Movement
        • Transform Movement
        • Transform Rotation
        • Transform Scaling

Building Flappy Bird

Phase 1

  1. Set the Scene
    1. Create a scene
    2. Introduce the camera
      1. Set the aspect ratio
    3. Add in a background
      1. Import the image
      2. Create an empty game object
      3. Add a sprite renderer
      4. Apply the sprite
      5. Tweak the scaling (2.0f, 1.5f, 1.0f)
  2. Add in the Character
    1. Create the character
      1. Import the image
      2. Create an empty game object
      3. Add the sprite renderer
      4. Apply the sprite
    2. That's a big bird!
      1. Adjust the camera (Orthographic 9)
      2. Adjust the bird scaling (0.25, 0.25, 1.0f)
    3. Time for gravity
      1. Add a Rigidbody2D to the bird
      2. Falls kinda slow? Increase it's mass (5, 500, 1000000)?
        1. What falls faster? 1lb of lead or 1lb of wood?
      3. Time to increase gravity scaling (2)
    4. Time to learn how to jump
      1. Add a BirdController.cs script
      2. Add an Update loop for input
      3. Add a FixedUpdate for input to change the velocity
      4. Set the force to be 5
      5. Tweak until it feels good (600)
  3. We've made a "flappy" bird!

Phase 2

  1. Build our pipes
    1. Create a pipe
      1. Create an empty game object
      2. Import our pipe pieces
        1. Align to (0.0f, 0.0f, 0.0f)
        2. Scale them all to (5.0f, 5.0f, 1.0f)
        3. Cascade 6 pieces downwards, snapping with ctrl key
      3. Store in "Resources/Prefabs" as a prefab
      4. Add a BoxCollider2D
        1. Size (3.0f, 16.0f)
        2. Offset (0.0f, -6.0f)
    2. Place the pipe below the bird
      1. Does it collide?
      2. Add a BoxCollider2D to the bird
      3. Now the collide!
    3. Combine 2 pipes into an "obstacle"
      1. Rotate one pipe to (0.0f, 0.0f, 180.0f)
      2. Move it's "local space" to (0.0f, +/-5.0f, 0.0f)
      3. Combine under a new game object and store as a prefab
  2. Time for more pipes!
    1. Create a GameManager
      1. Create GameManager.cs
      2. Add Update loop
      3. Add in time management code
      4. Add in object instantiation code
      5. Add in transform.position assigment
    2. Test!
      1. We get obstacles, but they don't move?
      2. Add a script to the obstacles!
    3. Create PlatformMovement.cs
      1. Create PlatformMovement.cs
      2. Add Update loop
      3. Add transform.position movement code
      4. Play with the speed value to see what feels good (-4)
      5. Play with the GameManager wait time to feel better (3)
  3. We've now got all our set pieces in place

Phase 3

  1. Time to add in our "rules"
    1. Add in collision logic to BirdController.cs
    2. Make it restart on collision
    3. Background overlaps? Move it to the back
  2. Now we have the basics of the "game"!

Phase 4

  1. Time to add in our more meaningful "goal"
    1. Add in a Canvas
      1. Find the Hierarchy window (middle-left)
      2. Click the create button (top-left corner of the Hierarchy window)
      3. Navigate and click UI -> Canvas
    2. Add an empty child to the Canvas
      1. Right click Canvas in the Hierarchy
      2. Create empty
    3. Add in a Text component
    4. Move it's anchors to the top-left (box below "Rect Transform")
    5. Set it's position offset from the corner (50.0f, -50.0f)
    6. Change it's text size to something better (25)
  2. Upgrade our Obstacle
    1. Pull the prefab back into the scene
    2. Add a new child game object with a BoxCollider2D to the right side of the gap between pipes
      1. Move the position (3.0f, 0.0f, 0.0f)
      2. Adjust the size (3.0f, 6.0f)
    3. Time to adjust their layers so we can distinguish what we hit
      1. Add "Score" and "Death" layers
      2. Assign the Score game object to the "Score" layer
      3. Assign the Pipe game objects to the "Death" layer
    4. Press apply on the Obstacle game object to update our prefab
  3. Update our BirdController script
    1. Add in layer checking logic to the collision event
  4. Add in a script for handling the score
    1. Create ScoreManager.cs
    2. Add ScoreManager component to Score game object
    3. Add public field ScoreManager to BirdController
    4. Link the two in Unity (drag Score from the hierarchy onto the ScoreManager field in the Bird game object)
  5. Oh snap, the bird gets blocked!
    1. Make the Score collider a "trigger"
      1. Go to the Score game object and tick the "Is Trigger"
  6. It still doesn't work!!
    1. Move the Score check into OnTriggerEnter2D(Collider2D)
  7. Congrats, you've rebuilt flappy bird!

References

Tappy Plane Tutorial Background Art Bird Sprite Pipe Sprites

About

A short tutorial to show off the basics of Game Development and Unity3D

License:MIT License


Languages

Language:C# 100.0%