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
Outline
- What Is Unity?
-
Why Unity?
-
Concepts
- Coding
-
Neat Stuff
Foolish Assumptions
You know something about programming language
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.
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.
Unity 2d Showcase
Why Unity?
-
Built in Visual Scene Editor
- Particle Editor
- Animation Editor (Mecanim)
- Entity Based Development
- Asset Store
- Multiple Programming Language Support
- (C#, Javascript*, Boo)
Unity at GDC 2014
Why Unity (cont.)
- Flexible Asset Pipeline
-
Multi-Platform
- Licensing
- Large and generally friendly community
Concepts
-
Component
- GameObject
-
Prefab
- Scene
- Asset
- Sprite
- Scene
- 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
-
Sprite - A two dimensional "2d" Image
-
Sprite Sheet - A large 2d image containing a collection of smaller images or "Sub Images" a.k. Texture Atlas
- Lots of examples
- Recommend:The Almighty Grass Tile
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
-
Awake Calls
-
Start Calls
- Fixed Updates (Can be called multiple times)
- Physics
- Triggers
- Collision
- Updates
- Animations
- Rendering
Neat Stuff
Questions?
2d w Unity
By Terrance Smith
2d w Unity
Starting 2d Game Development with Unity 4.3 Native 2d tools
- 1,470