Starting 2d Game Development 
with Unity 4.3 Native 2d tools

Who Am I?



Terrance Smith


Who Am I?




  • Father (Always Father first)
  • Professional Software Developer (Since 2008 or so)
  • All around IT Guy (Since 2003 or so)
  • Aspiring Game Developer 
  • Gamer 

hackerferret.com
musicm122.blogspot.com
About Me

Outline



  • What Is Unity?
  • Why Unity?
  • Concepts
  • Coding
  • Neat Stuff

Foolish Assumptions





You know something about programming language

You know what a game loop is

You know what collision detection is

WHAT IS UNITY


Unity is a cross-platform game engine with a built-in IDE developed by Unity Technologies. It is used to develop video games for web plugins, desktop platforms,consoles and mobile devices.



Made With Unity

Unity 2d Showcase


Why Unity?



Unity at GDC 2014


Why Unity (cont.)



Concepts




  1. Component
  2. GameObject
  3. Prefab
  4. Scene
  5. Asset
  6. Sprite
  7. Scene
  8. Mecanim Animation

Components



A single unit of functionality often bound to a single domain. 


GameObjects


Container for components


Prefab






A reusable GameObject

Asset


Any content that is in your project

  • Images 
  • Scripts 
  • Models 
  • Audio
  • Video
  • Prefab
  • Scene
  • Animation
  • Font

About the Asset Store




Mike Bithell: The Asset Store is a path to more ambitious indie games

Sprite


Which Is A Sprite?

 


Sprite





Pixel Art


Pixel Art



Pixel Art



Scene






Container for the objects in your game

Animation





Mecanim - Visual programming based animation system

Coding Concepts




  • MonoBehavior
  • Getting Input
  • Collision Detection
  • Coroutines
  • Update Loop "Execution Order"

MonoBehavior





  • MonoBehavoir - The base class from which scripts are derived from 
  • Contains functions that hook into the majority of Unity's "Events" including object lifecycle, Gui, Collision, User Input, Networking etc...
  • Contans functions for query of gameobjects and components based on tag, layer, type, relationship etc...

Getting Input


Code Example

using UnityEngine;
using System.Collections;

public class Example : MonoBehaviour {
    public GameObject projectile;
    void Update() {
        if (Input.GetButtonDown("Fire1"))
            Instantiate(projectile, transform.position, transform.rotation) as GameObject;
        
    }
}


Collision Detection



Code Example

using UnityEngine;
using System.Collections;

public class Example : MonoBehaviour {
    void OnCollisionEnter2D(Collision2D coll) {
        if (coll.gameObject.tag == "Enemy")
            coll.gameObject.SendMessage("ApplyDamage", 10);
        
    }
}

Coroutines





  • Coroutine-A function that can suspend execution "yield" until a given time
  • Used for time and frame specific actions that require deferred execution
  • Used a lot internally in Unity to implement the "Game Loop"

Execution Order



Execution Order

Of a single Frame

  1. Awake Calls
  2. Start Calls
  3. Fixed Updates (Can be called multiple times)
    1. Physics
    2. Triggers
    3. Collision
  4. Updates
  5. Animations
  6. Rendering





Neat Stuff





Questions?