Game Design From Concepts To Implementation

Similar documents
Terrain. Unity s Terrain editor islands topographical landscapes Mountains And more

Google SketchUp/Unity Tutorial Basics

Adding a Trigger to a Unity Animation Method #2

Terrain. Unity s Terrain editor islands topographical landscapes Mountains And more

IAT 445 Lab 10. Special Topics in Unity. Lanz Singbeil

This allows you to choose convex or mesh colliders for you assets. Convex Collider true = Convex Collider. Convex Collider False = Mesh Collider.

Unity Software (Shanghai) Co. Ltd.

Introduction to Unity. What is Unity? Games Made with Unity /666 Computer Game Programming Fall 2013 Evan Shimizu

8iUnityPlugin Documentation

Unity Scripting 4. CS 491 / DES 400 Crea.ve Coding. Computer Science

Transforms Transform

if(input.getkey(keycode.rightarrow)) { this.transform.rotate(vector3.forward * 1);

Merging Physical and Virtual:

Tutorial Physics: Unity Car

User Manual. Contact the team: Contact support:

NOTTORUS. Getting Started V1.00

Unity Tutorial. Fall /15-666

UFO. Prof Alexiei Dingli

ANIMATOR TIMELINE EDITOR FOR UNITY

8iUnityPlugin Documentation

Game Design Unity Workshop

Tutorial: Using the UUCS Crowd Simulation Plug-in for Unity

is.centraldispatch Documentation

Workshop BOND UNIVERSITY. Bachelor of Interactive Multimedia and Design. Asteroids

Unity3D. Unity3D is a powerful cross-platform 3D engine and a user friendly development environment.

Planet Saturn and its Moons Asset V0.2. Documentation

Bonus Chapter 10: Working with External Resource Files and Devices

Setting up A Basic Scene in Unity

Auto Texture Tiling Tool

Previously, on Lesson Night... From Intermediate Programming, Part 1

Game Design Unity Workshop

COMS W4172 : 3D User Interfaces Spring 2017 Prof. Steven Feiner Date out: January 26, 2017 Date due: January 31, 2017

Cláudia Ribeiro PHYSICS

Workshop BOND UNIVERSITY Bachelor of Interactive Multimedia and Design Beginner Game Dev Character Control Building a character animation controller.

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Unity

Auto Texture Tiling Tool

Game Design Unity Workshop

UNITY WORKSHOP. Unity Editor. Programming(Unity Script)

User Manual. Version 2.0

OculusUnityMatlab Documentation

Pacman. you want to see how the maze was created, open the file named unity_pacman_create_maze.

8K Earth, Moon and Mars Shaders Asset V Documentation

About the FBX Exporter package

Introduction to Unreal Engine Blueprints for Beginners. By Chaven R Yenketswamy

Mechanic Animations. Mecanim is Unity's animation state machine system.

How to add new 3D Models to Machines Simulator 3 & Machines Simulator VR

Pong in Unity a basic Intro

Progress Bar Pack. Manual

Easy Decal Version Easy Decal. Operation Manual. &u - Assets

Tutorial: Importing static mesh (FBX)

Section 28: 2D Gaming: Continuing with Unity 2D

Dice Making in Unity

Creating a 3D Characters Movement

Contents Interior Mapping & Transistions... 1

Underwater Manager (Optional)

Optimizing and Profiling Unity Games for Mobile Platforms. Angelo Theodorou Senior Software Engineer, MPG Gamelab 2014, 25 th -27 th June

Introduction This TP requires Windows and UNITY 5.

IAP Manager. Easy IAP Workflow. Copyright all rights reserved. Digicrafts 2018 Document version Support

PROTOTYPE 1: APPLE PICKER FOR UNITY 5.X

PERFORMANCE. Rene Damm Kim Steen Riber COPYRIGHT UNITY TECHNOLOGIES

Damaging, Attacking and Interaction

Distributed Programming

Mobile Speech Recognizer

User Manual v 1.0. Copyright 2018 Ghere Games

VEGETATION STUDIO FEATURES

OSC. Simplification. Asset Store Description 2 Underlying Concepts 3 Getting started 4

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch

Dungeons+ Pack PBR VISIT FOR THE LATEST UPDATES, FORUMS, SCRIPT SAMPLES & MORE ASSETS.

THE LAUNCHER. Patcher, updater, launcher for Unity. Documentation file. - assetstore.unity.com/publishers/19358

Spell Casting Motion Pack 5/5/2017

Table of Contents. Questions or problems?

Tutorial: Working with Lighting through Components

CS248 Lecture 2 I NTRODUCTION TO U NITY. January 11 th, 2017

Fundamentals. 5.1 What Will Be Covered in This Chapter. 5.2 Review

Intel RealSense SDK Gesture Sequences Implemented in Unity* 3D

3D Starfields for Unity

Extract from NCTech Application Notes & Case Studies Download the complete booklet from nctechimaging.com/technotes

MaxstAR SDK 2.0 for Unity3D Manual. Ver 1.2

Copyright All Rights Reserved

Add in a new balloon sprite, and a suitable stage backdrop.

Creating and Triggering Animations

Tutorial: Creating a Gem with code

JACK4U Manual. vers. 1.1

C# for UNITY3d: Sem 1 a.k.a. The Gospel of Mark Part 1

UI Elements. If you are not working in 2D mode, you need to change the texture type to Sprite (2D and UI)

Introduction into Game Programming (CSC329)

Unity introduction & Leap Motion Controller

Creating the Tilt Game with Blender 2.49b

Coin Pusher Pro Asset - README

Intermediate. 6.1 What Will Be Covered in This Chapter. 6.2 Review

INTRODUCTION 3 SYSTEM REQUIREMENTS 4 PACKAGE CONTENT 4 CHANGELOG 4 FAST GUIDE 8 PSD2UGUI IN DEPTH 12 PSD LAYERS STRUCTURES 14

Planets Earth, Mars and Moon Shaders Asset V Documentation (Unity 5 version)

Pong. Prof Alexiei Dingli

Physically Based Shading in Unity. Aras Pranckevičius Rendering Dude

Pick up a book! 2. Is a reader on screen right now?! 3. Embedding Images! 3. As a Text Mesh! 4. Code Interfaces! 6. Creating a Skin! 7. Sources!

Better UI Makes ugui Better!

Dialog XML Importer. Index. User s Guide

Chart And Graph. Features. Features. Quick Start Folders of interest Bar Chart Pie Chart Graph Chart Legend

Assignment 4: Flight Simulator

PixelSurface a dynamic world of pixels for Unity

Transcription:

Game Design From Concepts To Implementation Giacomo Cappellini - g.cappellini@mixelweb.it

Why Unity - Scheme Unity Editor + Scripting API (C#)! Unity API (C/C++)! Unity Core! Drivers / O.S. API! O.S.! Hardware!

Unity Licenses Pro Unity Editor + Scripting API (C#)! Unity API (C/C++)! Unity Core! Drivers / O.S. API! O.S.! Hardware!

Unity Licenses Free Main limitations: No custom splash screen No video playback No native plugins (call platform functions from Unity scripts) No realtime shadows No fullscreen post-processing effects No navigation meshes (path finding) Complete list at: http://unity3d.com/unity/licenses

Unity Licenses Free Unity Editor + Scripting API (C#)! Unity API (C/C++)! Unity Core! Drivers / O.S. API! O.S.! Hardware!

Why Unity Cross Platform When working on top of Unity Unity Editor + Scripting API (C#)! Unity Core will take care of every cross-platform issue Unity Core! Here is where black magic happens - We don t have any access to it - You can just try to guess what s going on under the hood

Unity physical dissection Unity Editor PhysX engine Collection of asset importers Customized Mono environment Per-Platform Mono compiler MonoDevelop IDE Documentation + Scripting reference

Project script = Mono libraries Mono is an open source implementation of Microsoft's.NET Framework based on the standards for C#. In other words, it s a system that you can use to compile C# code and run it on different platforms. You may compile your code as an executable (.exe) or a library (.dll) Unity compiles your code into a.dll and calls the functions inside the Unity core

Components and Scripting

Unity logical dissection Scene = A holds zero or more of B GameObject Script (Component) Assets Material Shader Mesh Sound Texture Binary

Component A component is a Unity Script that has been attached to a GameObject There s no limit to the number of components you can assign to a GameObject The code that you write in your Unity Script should describe a single Behaviour The sum of the behaviours describes the real nature of the GameObject itself

Component Components are the most important part of your logic Unity comes with a limited number of built-in components You can use b.i.c. to send instructions to: Render system Physics system Audio system and others You can think of built-in Components as special scripts that are able to use private API functions that you cannot use inside custom scripts.

Component By using custom components you are able to call functions on different components on the same GameObject, or on a different GameObject, or use external resources and even modify the behaviour of the whole Engine. Assets Material Shader Mesh Sound Texture Binary We will expose later some of the power features of the Unity Scripting Engine

Component FlyBehaviour.cs Eagle It wanders around It flies WandererBehaviour.cs Wolf It wanders around It howls HowlingBehaviour.cs You can save a lot of coding by using behaviour combination

Component -- AVOID THIS WHENEVER POSSIBLE -- EagleBehaviour.cs Eagle Wolf WolfBehaviour.cs

Unity Editor - Working with Components -

Creating a new project You are given a form to select the project destination path and a checkbox list of packages. Packages are compressed bundles of Scripts and Assets that you can import on project initialization or at a later time.

GameObject Create Other Empty An Empty GameObject has no graphics and no behaviour, it has noting but a Transform. It is a point in space ready to be configured. It s like the steam cell of any game element.

GameObject Naming and tagging You can rename any GameObject by slowly double-click on it inside Hierarchy window or by using the Inspector s name field You can also assign a tag to the GameObject Tags can be used by scripts to search throughout the hierarchy tree.

Editor Components If you take a look inside the Hierarchy Create menu or GameObject Create Other menu you find a set of predefined GameObjects The differences between a predefined GameObject and an Empty GameObject are the Components that it comes with when created Now create end select a Cube

Editor Components You can think of a Cube like an Empty with: 1. A Mesh Filter Component 2. A Mesh Renderer Component 3. A Box Collider Component WARNING: Transform is not a Component. You cannot remove the Transform from the GameObject that owns it

Editor Components 1. Component Mesh Mesh Filter 2. Component Mesh Mesh Renderer 3. Component Physics Box Collider

Editor Attributes Components have attributes and options Mesh Filter: has a Mesh attribute of type Mesh Mesh Renderer: Has 3 Booleans (Cast/Receive Shadows + Light Probes ) and an Array of Material Box Collider: Has 1 Boolean, a Physics Material, and 2 Vector3 fields ( Center and Size )

Custom Objects 1. Create an Empty GameObject 2. Name it Custom Cube 3. Add these two components on Custom Cube 1. Mesh -> Mesh Filter 2. Mesh -> Mesh Renderer 3. Physics -> Sphere Collider 4. Set the mesh attribute of the Mesh Filter component to Cube 5. Set the Materials -> Element 0 attribute to Default-Diffuse Now compare your Custom Cube and the Cube object we have previously created

Editor Custom Components Custom Component = Unity Script Assets Create C# Script using UnityEngine; using System.Collections; public class MyFirstScript : MonoBehaviour { // Use this for initialization void Start () { Name it MyFirstScript and double click on it: MonoDevelop will start } } // Update is called once per frame void Update () { }

Editor MonoDevelop

Editor MonoDevelop MonoDevelop is an Integrated Development Environment originally made for working with the Mono Framework and later adapted for being Unity s default script editor Note: MonoDevelop is not the COMPILER of your executable code. You can use the Build function to check the correctness of your code, but Unity will re-compile your files internally and without asking after any code modification. You can also edit your files using your preferred text editor.

Editor Custom Components Now drag the Script you ve just created from the Project window on any GameObject in your Hierarchy window. Ta-Dah! You ve just turned a Script into a Component! This is the starting point of any custom logic of your game. Inside the C# Script you re expected to describe the Behaviour of every GameObject with the same script attached.

Editor MonoBehaviour Every Script is a new C# new class that extends MonoBehaviour http://docs.unity3d.com/documentation/scriptreference/monobehaviour.html

Editor Script Attributes using UnityEngine; using System.Collections; public class MyFirstScript : MonoBehaviour { public bool mycustombool; public float mycustomfloat; public int mycustomint; public Vector3 mycustomvector3; public AudioClip mycustomaudioclip; public Mesh mycustommesh; public Material mycustommaterial; // Use this for initialization void Start () { } // Update is called once per frame void Update () { Now some magic: public attributes = Component options! } }

Editor Script Attributes

Editor Script Attributes Every Component is sharing the same C# code but the attributes/options are different on each GameObject

Start() function and Update() function When you create a new Script, you are given this template // Use this for initialization void Start () { } // Update is called once per frame void Update () { } You are expected to write your code into those functions but, how to use them? Do you know what a frame is?

What is a frame? A frame is an unique image, just like in movies The frame rate (aka frames per second or fps) are: how many frames your hardware is able to compute in 1 second Depending on: the capabilities of your hardware the complexity of your scene the available resources the fps of your running project won t be constant, and you shouldn t assume that.

Frame -> Update() Frames are being calculated by your hardware fast as possible To achieve game that doesn t look and feel bad you need, at least, to have 30fps. Otherwise your game will just feel stuttering all the time. The Update() function is getting called, on each script, every time Unity computes a new Frame 30fps =~ 0.0333s per frame 60fps =~ 0.0166s per frame So, you should do (very) small changes on each Update call

Frame -> Update() + transform http://docs.unity3d.com/documentation/scriptreference/transform.html Or just search Unity Transform on the Internet You see a number of variables and functions available on the Transform object. You can type something like: transform.translate( 1, 0, 0 ); Inside your Update() function, just between the braces. Save the.cs modification (ctrl+s) and switch back to Unity What s going to happen?

Frame -> Update() + transform transform.translate( 1, 0, 0 ); Is like adding 1 on the X value of the position of the object s transform, every frame. It means that the object is going to move on the X axis by frames per second units every second So IF your hardware is able to perform 200 fps, the object would move 200 units every second. And it would go slower on different hardware or just when your computer gets busy doing calculating else. You don t want that, you want your game to work in a framerate independent way.

Time.deltaTime Your workstations are probably able to compute more than 200 fps inside our simple scene. Inside your Update() function you can use a float value named Time.deltaTime to make the modifications in your scene frames per second independent. Time.deltaTime contains the time (in seconds) that Unity has spent while calculating the previous frame. How about: transform.translate( 1 * Time.deltaTime, 0, 0 );

Feedback from your script While writing your script you have 2 ways to get feedback from your logic. 1. Run the script and check if it s behaving like expected. 2. Use Debug.Log( Some text ) and ask for a value: Debug.Log( The local X is + transform.localposition.x ); Debug.Log( The global X is + transform.position.x ); Debug output will be printed inside Unity Console. Open it using Window -> Console

Scripting Playground Download the Unity Project here: http://bit.ly/1bbwtyr Goals: 1. Fix Translate script using deltatime 2. Fix Rotate script using deltatime 3. Make Rotate use one or more variables as input instead of constants, just like TranslateWithVariable 4. Fix TranslateWithVariable using deltatime Brave enough? Make a script that moves that moves on the right (+X), but after 5 seconds it starts going the other way (-X). HINT: create a float variable and add Time.deltaTime to it each frame, then use it to calculate how much time has passed.