SE 350 – Programming Games Lecture 6: Programming with Unity Lecturer: Gazihan Alankuş Please look at the last slide for assignments (marked with TODO)

Slides:



Advertisements
Similar presentations
Introduction to Macromedia Director 8.5 – Lingo
Advertisements

SE 320 – Introduction to Game Development Lecture 5: Programming in Unity & Developing Simple Games Lecturer: Gazihan Alankuş Please look at the last two.
Intro to CIT 594
INNER WORKINGS OF UNITY 3D. WHAT WE ARE GOING TO COVER Intro to Unity Physics & Game Objects Cameras & Lighting Textures & Materials Quaternions and Rotation.
SE 313 – Computer Graphics Lecture 14: Armatures Lecturer: Gazihan Alankuş 1.
GameCamp! and Game Davis Introduction to Scripting in Unity®
CSSE221: Software Dev. Honors Day 10 Announcements Announcements Fifteen due Monday 11:59 pm. Monday will be a workday. Fifteen due Monday 11:59 pm. Monday.
HELLO WORLD: YOUR FIRST PROGRAM CHAPTER Topics  Hello World?  Creating a Unity Project –The Unity Project Folder  MonoDevelop: Unity's Code Editor.
SE 320 – Introduction to Game Development Lecture 1: Introduction Lecturer: Gazihan Alankuş Please look at the last two slides for assignments (marked.
SE 350 – Programming Games Lecture 1: Introduction Lecturer: Gazihan Alankuş Please look at the last two slides for assignments (marked with TODO) 2/10/20121.
Software Development. Chapter 3 – Your first Windows 8 app.
CS 115 TA Orientation Fall More students! Enrollment up to sections + night about 22% CS majors (50 on 8/16)
SE 320 – Introduction to Game Development Lecture 11: Animations and GoKit Lecturer: Gazihan Alankuş Please look at the last slides for assignments (marked.
Every week: Sign in at the door If you are new: Fill in Registration Form Ask a Mentor how to get started Make sure you are on the Athenry Parents/Kids.
SE 204, IES 506 – Human Computer Interaction Lecture 5: Class Practice on the Design Process Lecturer: Gazihan Alankuş Please look at the end.
SE 320 – Introduction to Game Development Lecture 4: Programming in Unity & Project Presentations Lecturer: Gazihan Alankuş Please look at the last two.
SE 204, IES 506 – Human Computer Interaction Lecture 1: Introduction Lecturer: Gazihan Alankuş Please look at the last two slides for assignments (marked.
David, on using MonoDevelop David, on getting to edit and debug in Visual Studio.
DEBUGGING CHAPTER Topics  Getting Started with Debugging  Types of Bugs –Compile-Time Bugs –Bugs Attaching Scripts –Runtime Errors  Stepping.
UFCEKU-20-3Web Games Programming Unity 3D Basic Concepts Using and Creating Prefabs.
EEC-693/793 Applied Computer Vision with Depth Cameras Lecture 13 Wenbing Zhao
SE 350 – Programming Games Lecture 1: Introduction Lecturer: Gazihan Alankuş Please look at the last two slides for assignments (marked with TODO) 2/10/20121.
SE 320 – Introduction to Game Development Lecture 8: Animations, GUIs, Debugging and IDEs Lecturer: Gazihan Alankuş Please look at the last two slides.
SE 350 – Programming Games Lecture 7: Programming with Unity Lecturer: Gazihan Alankuş Please look at the last slide for assignments (marked with TODO)
Welcome to CS 115! Introduction to Programming. Class URL Write this down!
UFCFS D Technologies for the Web Unity 3D: Review of Topics and Related Concepts.
SE 313 – Computer Graphics Lecture 6: Transformations Lecturer: Gazihan Alankuş Please look at the last three slides for assignments (marked with TODO)
Presented by IBM developer Works ibm.com/developerworks/ 2006 January – April © 2006 IBM Corporation. Making the most of The Eclipse debugger.
Learning Unity. Getting Unity
SE 204, IES 506 – Human Computer Interaction Lecture 8: Review for Midterm Lecturer: Gazihan Alankuş 1 Please look at the end of the presentation for assignments.
SE 320 – Introduction to Game Development Lecture 3: Unity’s Interface and Concepts Lecturer: Gazihan Alankuş Please look at the last two slides for assignments.
SE 320 – Introduction to Game Development Lecture 7: Programming Lecturer: Gazihan Alankuş Please look at the last two slides for assignments (marked with.
INTRODUCTION TO PROGRAMMING ISMAIL ABUMUHFOUZ | CS 146.
UFCEK-20-3Web Games Programming Unity 3D: Review of Topics Publishing for the Web.
Problem Solving Methodology Rachel Gauci. Problem Solving Methodology Development Design Analysis Evaluation Solution requirements and constraints. Scope.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 4 Slide 1 Slide 1 What we'll cover here l Using the debugger: Starting the debugger Setting.
Derived from Kirill Muzykov’s Rocket Mouse Tutorial WakeUpAndCode.com.
SE 320 – Introduction to Game Development Lecture 2: Introduction to Unity Lecturer: Gazihan Alankuş Please look at the last two slides for assignments.
CLASSES CHAPTER Topics  Understanding Classes –The Anatomy of a Class  Class Inheritance –Superclasses and Subclasses –Virtual and Override 2.
GameDevClub CODE CHEAT SHEET NOTE: ALL OF THE CODE IS CASE-SENSITIVE AND THE SYNTAX IS STRICT SO A LOT OF YOUR ERRORS WILL PROBABLY COME FROM TYPOS If.
SE 350 – Programming Games Lecture 5: Programming with Unity Lecturer: Gazihan Alankuş Please look at the last slide for assignments (marked with TODO)
SE 313 – Computer Graphics and Visual Programming Lecture 6: Geometric Transformations Lecturer: Gazihan Alankuş Please look at the last slides for assignments.
Today's Ninja Challenge: Write Your First Computer Game!
UFCEKU-20-3Web Games Programming Instantiating World Objects.
Expressive Intelligence Studio // Center for Games and Playable Media // Unity Pro John Murray Expressive.
Cosc 5/4735 Unity 3D Getting Started Guide for Android.
SE320: Introduction to Computer Games Week 3 Gazihan Alankus 10/4/20111.
Yingcai Xiao Game Development with Unity3D Inside/Outside Unity3D.
Christa Marsh Southern Arkansas University Biology Professor.
Get Secure! Facebook Privacy Tutorial Becky Benishek | November 2013.
Computer Science I ISMAIL ABUMUHFOUZ | CS 180. CS 180 Description BRIEF SUMMARY: This course covers a study of the algorithmic approach and the object.
Behavior trees & The C# programming language for Java programmers
Digital Game Design ACST 3710 Your First Unity Program 1.
Game Development with Unity3D
Welcome! Day1, Lesson 1.
EEC-693/793 Applied Computer Vision with Depth Cameras
Quick Intro to Unity Lecture 2.
Development Environment
EEC-693/793 Applied Computer Vision with Depth Cameras
Introduction to Events
EEC-693/793 Applied Computer Vision with Depth Cameras
Managing Your Literature Search Using Zotero
Welcome to CS 1010! Algorithmic Problem Solving.
UNITY TEAM PROJECT TOPICS: [1]. Unity Collaborate
A beginner’s tutorial for Unity and VR
Week 6: Time and triggers!
Introduction to Unity 2D Game Development
EEC-693/793 Applied Computer Vision with Depth Cameras
CMPE212 – Reminders Assignment 2 due today, 7pm.
Unity Game Development
Presentation transcript:

SE 350 – Programming Games Lecture 6: Programming with Unity Lecturer: Gazihan Alankuş Please look at the last slide for assignments (marked with TODO) 2/10/20121

Today Cover most topics about scripting in Unity 2/10/20122

The BEST Development Environment for Unity Scripting that I Know of Visual Studio + Resharper for coding – I asked for a classroom license. I also sent an . Still waiting. In the meantime go ahead and install the 30 day version. MonoDevelop for occasional line-by-line debugging (explained towards end of presentation) If you are using any other way, you would certainly develop a better game if you listen to me (If you disagree, talk to me before discarding my advice… I have worked on large projects.) 2/10/20123

Pointer Fun with Binky No class talking about references is complete without Binky! This is not a joke. If you don’t get why you watched it, please ask. _with_Binky_(Java).ogg _with_Binky_(Java).ogg 2/10/20124

Variables with class Types are References Variables with struct Types are values Transform transform; GameObject myObject; Structs do not work that way – Vector3, Quaternion, etc. – Vector3 v = new Vector3(0, 0, 1); – Vector3 v1 = v; – v1.x = 1; – //v.x == 0 still 2/10/20125

Operator Overloading Vector3 v3 = new Vector3(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z); Is equivalent to Vector3 v3 = v1 + v2; 0.5 * Vector3.up – Etc. 2/10/20126

Components and Scripts Components are added to game objects and appear in the inspector Scripts (MonoBehavior) are custom components that you create – public variables appear in the inspector – Can have functions for handling GameObject’s events (Update, OnCollisionEnter, etc.) 2/10/20127

Game Objects and Components Your code runs in the context of the component You can access – The game object that it is attached to gameObject – Other components that are attached to the same game object GetComponent () Shortcuts for standard components (transform, renderer, etc. ) – Parent game object in the hierarchy transform.parent.gameObject – Other game objects in the scene GameObject.Find(“Game object’s name”) – There are more (find all components in this hierarchy, etc.) 2/10/20128

Accessing Things 2/10/20129 Cube Transform MyOtherScript (MonoBehavio r) MyScript (MonoBe havior) Game ObjectComponents GetComponent () transform gameObject GetComponent(“MyOtherScript”) GetComponent () GetComponent(“Transform”) Bushes GameObject.Find(“Bushes”) Red text shows how this component accesses others

Using the Inspector as a Guide Don’t try to memorize anything. Just look at the inspector and you’ll figure it out. 2/10/201210

If you can do it through the user interface, you can script it You can access anything You can tell them to do anything Use the inspector and hierarchy as starting points 2/10/201211

Which Game Object Do You Attach Your Script to? It only changes – Whose components you want to access easily – Whose events you want to react to If these are not important for the script, it can be in one of the standard objects (camera, etc.) 2/10/201212

Let’s do some examples How do I reach this object? How do I tell him to do something? 2/10/201213

Better Ways of Scripting Reaching game objects by name – Is slow (string comparisons) – Is static (have to have that specific name, difficult to reuse for something else) Another way is to expose references in the inspector (public) and make connections in the user interface However, the inspector can be an overkill, and you still may want to find game objects by name – Don’t keep calling GameObject.Find() and GetComponent() – Make connections in the Awake() function It’s faster to use references that are already set 2/10/201214

Connecting Objects in Awake() Awake runs before anything else. So, it is the preferred place for setting up connections – otherObject = GameObject.Find(“other object”); – otherComponent = GetComponent () – Later use these variables during the game, just like you use the references to the standard components (transform, renderer, etc.) 2/10/201215

Creating and Destroying Objects while the Game is Running Instantiate(game object or prefab, position, rotation) Destroy(game object) 2/10/201216

Some Basic Data Types (struct, not class) Vector3 – For positions and directions Quaternion – For orientations and rotations 2/10/201217

Transform transform.position transform.rotation – With respect to the world. Changes when parent changes. – Not what you see in the inspector. transform.localPosition transform.localRotation transform.localScale – With respect to the parent. Does not change when parent changes. – What you see in the inspector transform.right, transform.up, transform.forward – x, y, z axes that you see 2/10/201218

Data Structures with Unity Don’t underestimate. It’s C#! You can do anything! Classes, objects, references Variables, structs Collections ArrayList, List<>, Dictionary – using System.Collections.Generic; Enums Classes in separate files or within other classes – Use them to group variables together This would help even if you don’t know Java: – 2/10/201219

Some Coding Demonstration 2/10/201220

Debugging with MonoDevelop while Coding in Visual Studio at the Same Time Do this once after you created your Unity project – Edit->Preferences->External Tools is where you set the IDE that Unity will fire Select Visual Studio – Double-click a script, this will create the Visual Studio project Select MonoDevelop – Double-click a script, this will get the project in MonoDevelop’s recents Select Visual Studio again – Close everyting Do this at every run – Run MonoDevelop without running Unity – Select the project that is already in the recent projects – Run->Debug This will run Unity – Set a breakpoint in MonoDevelop and see how it stops at that breakpoint – Run Visual Studio by either running it from the start menu, Or ensuring Edit->Preferences->External Tools is Visual Studio and double clicking on a script. – This does not affect MonoDevelop 2/10/201221

How to go about working with code Access what you are interested in – Easy, just use the inspector as a guide Get the value, it will probably be an object of a class – For example: Vector3 Read about it in the script reference – erence/ erence/ Also, search for random stuff in the script reference. It’s likely to lead in the right direction. 2/10/201222

How to improve yourself in C# Unity and C# tutorials in catlikecoding.com are good Development-for-Absolute-Beginners is not bad. If you don’t have enough time, watch 9, 14, 15, 21 Development-for-Absolute-Beginners It’s fastest to learn from examples! – The five games that you already saw: 2/10/201223

TODO: Projects Every member of the group will send me a separate weekly report about what you did that week about the project – This is private. Do not share with others. – Just write it as an . No attaching word documents or pdfs please! – Send them every Thursday night! 2/10/201224

TODO: Midterm Exam Date: 21 March 2012 Time: 18: :20 Place: A2 No questions about the Maya interface 2/10/201225