kinect practicum 179 lecture 7

Upload: jesus-rincon

Post on 04-Jun-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 Kinect Practicum 179 Lecture 7

    1/29

  • 8/13/2019 Kinect Practicum 179 Lecture 7

    2/29

    Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    Unity from 10,000 feet

    An IDE designed to accelerate game design Composes and describes relationships

    between assets, scripts and scenes Allows rapid development cycles, live

    previews and tweaking while game runs

    Extensible (see GAK plugin)

  • 8/13/2019 Kinect Practicum 179 Lecture 7

    3/29

    Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    Why learn Unity?

    Can publish to a wide variety of platforms,including iPhone and Xbox 360

    Useful for prototyping a design quickly, asmany things (particles, collisions, and cameracontrols) have already been done for you

    Games created with unity include: BattlestarGalactica Online, Runespell, etc

  • 8/13/2019 Kinect Practicum 179 Lecture 7

    4/29

    Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    What Unity Doesnt Do

    Computer Vision Really Cool Things Unthought Of

    Experimental gameplay (Not traditionalfirst/third/etc. Basically Kinect)

    Depth/image information processing

  • 8/13/2019 Kinect Practicum 179 Lecture 7

    5/29

    Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    Unity Video Demo

    What can unity really do?

  • 8/13/2019 Kinect Practicum 179 Lecture 7

    6/29

    Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    THE UNITY INTERFACE

  • 8/13/2019 Kinect Practicum 179 Lecture 7

    7/29Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    Interface Layout

  • 8/13/2019 Kinect Practicum 179 Lecture 7

    8/29Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    Scene

    Navigation Edit GameObjects Scale/Rotate/Transform

  • 8/13/2019 Kinect Practicum 179 Lecture 7

    9/29Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    Navigation in Scene View

    Hold the right mouse button to enter Flythrough mode. This turns yourmouse and WASD keys (plus Q and E for up and down) into quick first-person view navigation.

    Select any GameObject and press the F key. This will center the SceneView and pivot point on the selection.

    Use the arrow keys to move around on the X/Z plane. Hold Alt and click-drag to orbit the camera around the current pivot point. Hold Alt and middle click-drag to drag the Scene View camera around.

    Hold Alt and right click-drag to zoom the Scene View. This is the same asscrolling with your mouse wheel.

  • 8/13/2019 Kinect Practicum 179 Lecture 7

    10/29Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    Positioning Game Objects

    Positioning GameObjects See Positioning GameObjects for full details on positioning GameObjects in the

    scene. Here's a brief overview of the essentials:

    http://unity3d.com/support/documentation/Manual/Positioning%20GameObjects.htmlhttp://unity3d.com/support/documentation/Manual/Positioning%20GameObjects.htmlhttp://unity3d.com/support/documentation/Manual/Positioning%20GameObjects.html
  • 8/13/2019 Kinect Practicum 179 Lecture 7

    11/29Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    Inspector

    Used for adjusting components Relationship between

    GameObjects and Componentsshown here

    Can enable/disable

    components and adjustparameters

  • 8/13/2019 Kinect Practicum 179 Lecture 7

    12/29

  • 8/13/2019 Kinect Practicum 179 Lecture 7

    13/29Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    Transform component

    Dont scale! Do scaling in Blender/Etc.

    ParentingWhen a GameObject is a Parent of another GameObject,the Child GameObject will move, rotate, and scale exactly as its Parentdoes. Just like your arms are attached to your body, when you turn yourbody, your arms move because they're attached. Any object can have

    multiple children, but only one parent.

  • 8/13/2019 Kinect Practicum 179 Lecture 7

    14/29Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    A note on Parenting and

    Transforms When parenting Transforms, set the parent's

    location to before adding the child.

    This will save you many headaches later. Particle Systems are not affected by the

    Transform's Scale . In order to scale a Particle

    System, you need to modify the properties inthe System's Particle Emitter, Animator andRenderer.

  • 8/13/2019 Kinect Practicum 179 Lecture 7

    15/29Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    Game ViewLive preview of game

  • 8/13/2019 Kinect Practicum 179 Lecture 7

    16/29Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    Game View Notes

    Any changes wont be baked in when game isrunning, need to reapply them

    Will reflect current position/state of objects inscene view as well

  • 8/13/2019 Kinect Practicum 179 Lecture 7

    17/29Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    CONCEPTS AND ELEMENTS

  • 8/13/2019 Kinect Practicum 179 Lecture 7

    18/29Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    GameObjects

    These are everything in Unity arerepresented in various ways in interface and in

    the code Can navigate between them using scripts

  • 8/13/2019 Kinect Practicum 179 Lecture 7

    19/29

  • 8/13/2019 Kinect Practicum 179 Lecture 7

    20/29Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    Particle Systems/Physics

    Collidable

  • 8/13/2019 Kinect Practicum 179 Lecture 7

    21/29Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    SCRIPTING

  • 8/13/2019 Kinect Practicum 179 Lecture 7

    22/29Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    Scripting

    Scripting Overview Scripting inside Unity consists of attaching custom script objects called

    behaviours to game objects.

    Different functions inside the script objects are called on certain events. Update:

    This function is called before rendering a frame. This is where most game behaviour code goes, except physics code.

    FixedUpdate:

    This function is called once every physics time step.

    This is the place to do physics-based game behaviour.

    Code outside any function : Code outside functions is run when the object is loaded. This can be used to initialise the state of the script.

    http://unity3d.com/support/documentation/Manual/Scripting.htmlhttp://unity3d.com/support/documentation/Manual/Scripting.html
  • 8/13/2019 Kinect Practicum 179 Lecture 7

    23/29

    Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    Examples of editing properties

    using UnityEngine;using System.Collections;

    public class example :MonoBehaviour {void Update() {transform.Translate(0, 0, 2);}}

    http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.htmlhttp://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.html
  • 8/13/2019 Kinect Practicum 179 Lecture 7

    24/29

    Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    Timing

    public class example :MonoBehaviour {

    void Update() {transform.Rotate(0, 5 *Time.deltaTime , 0);}}

    http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.htmlhttp://unity3d.com/support/documentation/ScriptReference/Time-deltaTime.html?from=indexhttp://unity3d.com/support/documentation/ScriptReference/Time-deltaTime.html?from=indexhttp://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.html
  • 8/13/2019 Kinect Practicum 179 Lecture 7

    25/29

    Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    Instantiation

    public class example : MonoBehaviour {public Transform explosion;void OnCollisionEnter() {Destroy(gameObject);Transform theClonedExplosion;theClonedExplosion = Instantiate(explosion,transform.position, transform.rotation) as

    Transform ;}

    }

    http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.htmlhttp://unity3d.com/support/documentation/ScriptReference/Transform.htmlhttp://unity3d.com/support/documentation/ScriptReference/Transform.htmlhttp://unity3d.com/support/documentation/ScriptReference/Transform.htmlhttp://unity3d.com/support/documentation/ScriptReference/Transform.htmlhttp://unity3d.com/support/documentation/ScriptReference/Transform.htmlhttp://unity3d.com/support/documentation/ScriptReference/Transform.htmlhttp://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.html
  • 8/13/2019 Kinect Practicum 179 Lecture 7

    26/29

    Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    Yield

    public class example : MonoBehaviour {IEnumerator Do() {

    print("Do now");

    yield return new WaitForSeconds (2);print("Do 2 seconds later");}void Example() {

    Do();print("This is printed immediately");

    }}

    http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.htmlhttp://unity3d.com/support/documentation/ScriptReference/WaitForSeconds.htmlhttp://unity3d.com/support/documentation/ScriptReference/WaitForSeconds.htmlhttp://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.html
  • 8/13/2019 Kinect Practicum 179 Lecture 7

    27/29

    Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    Working with Kinect Data

    Same data skeleteon joints as

  • 8/13/2019 Kinect Practicum 179 Lecture 7

    28/29

    Expressive Intelligence Studio http://eis.ucsc.edu

    Unity Pro CMPS179

    LIVE DEMO

  • 8/13/2019 Kinect Practicum 179 Lecture 7

    29/29

    Expressive Intelligence Studio // Center for Games and Playable Mediahttp://eis.ucsc.edu // http://games.soe.ucsc.edu

    Unity Pro

    John Murray