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

Similar documents
Class Unity scripts. CS / DES Creative Coding. Computer Science

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

Google SketchUp/Unity Tutorial Basics

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

Unity Game Development

MIXED REALITY (AR & VR) WITH UNITY 3D (Microsoft HoloLens)

MIXED REALITY (AR & VR) WITH UNITY 3D (Microsoft HoloLens)

UNITY WORKSHOP. Unity Editor. Programming(Unity Script)

Adding a Trigger to a Unity Animation Method #2

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

Game Design From Concepts To Implementation

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

Game Design Unity Workshop

Game Design Unity Workshop

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

VEGETATION STUDIO FEATURES

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

Transforms Transform

Auto Texture Tiling Tool

UFO. Prof Alexiei Dingli

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

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

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

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

Spell Casting Motion Pack 5/5/2017

Auto Texture Tiling Tool

Tutorial Physics: Unity Car

8K Earth, Moon and Mars Shaders Asset V Documentation

Game Design Unity Workshop

Setting up A Basic Scene in Unity

3dSprites. v

Creating a 3D Characters Movement

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

Basic Waypoints Movement v1.0

Planet Saturn and its Moons Asset V0.2. Documentation

Pong in Unity a basic Intro

OculusUnityMatlab Documentation

About the FBX Exporter package

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

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

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

Unity introduction & Leap Motion Controller

Table of contents. Introduction. Having finally realized your ambitious plans for a game, you might face big performance

GLOBAL SNOW Reference Guide

STEP 1: Download Unity

Dice Making in Unity

User Guide. v1.0. A-Lab Software

Tutorial: How to create Basic Trail Particles

You can also export a video of what one of the cameras in the scene was seeing while you were recording your animations.[2]

8iUnityPlugin Documentation

Quick Setup Guide. Date: October 27, Document version: v 1.0.1

ANIMATOR TIMELINE EDITOR FOR UNITY

3D Starfields for Unity

User Manual v 1.0. Copyright 2018 Ghere Games

Coin Pusher Pro Asset - README

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

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

User Manual. Luciano Rasente Asset Repository

Progress Bar Pack. Manual

Index. Allan Fowler and Philip Chu 2017 A. Fowler and P. Chu, Learn Unity 2017 for ios Game Development,

Research on the key technologies and realization of virtual campus

MODELING AND HIERARCHY

Creating and Triggering Animations

In this tutorial, you will create a scene with sandman dispersing in sand, as shown in in the image below.

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!

User Manual. Version 2.0

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

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

CMSC 425 Programming Assignment 1, Part 2 Implementation Notes

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

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

8iUnityPlugin Documentation

Using the API... 3 edriven.core... 5 A PowerMapper pattern... 5 edriven.gui... 7 edriven.gui framework architecture... 7 Audio... 9 Animation...

Chapter 1- The Blender Interface

Mobile Touch Floating Joysticks with Options version 1.1 (Unity Asset Store) by Kevin Blake

Vuforia quick install guide. Android devices and Unity 3D models edition

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

Pimax VR SDK_Unity. Development Documentation

Flames in Particle Flow

MEGACACHE DOCS. Introduction. Particle Simulations. Particle Exporters. Example Videos

DAZ Page 1. DAZ3D to Unity (Objects and Clothing)

Mount Points Mount Points is a super simple tool for connecting objects together and managing those relationships.

OFFICIAL DOCUMENTATION. Based on Suimono version Documentation last updated on 7/5/2016

Dialog XML Importer. Index. User s Guide

Burning Laser. In this tutorial we are going to use particle flow to create a laser beam that shoots off sparks and leaves a burn mark on a surface!

Merging Physical and Virtual:

Sidescrolling 2.5D Shooter

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

Chapter 19- Object Physics

Webinar Series. Virtual Reality. February 28 th, :00 PM EST. Hosted by Jeff Bertrand and Ginny Moore

Visual Novel Engine for Unity By Michael Long (Foolish Mortals),

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

Introducing Autodesk Maya Chapter 2: Jumping in Headfirst, with Both Feet!

Underwater Manager (Optional)

PSD to Mobile UI Tutorial

CSE 334 Research Paper. Name: Gene Chan. Date: Title: Constructing a physical figure into a 3d computer model.

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

Better UI Makes ugui Better!

Topic 10: Scene Management, Particle Systems and Normal Mapping. CITS4242: Game Design and Multimedia

Toon Boom Harmony Advanced V15.0

Transcription:

Unity Scripting 4 Unity Components overview Particle components Interaction Key and Button input Parenting CAVE2 Interaction Wand / Wanda VR Input Devices Project Organization Prefabs Instantiate

Unity Components Animation components Asset components Audio components Physics components The GameObject Image effect scripts Settings managers Mesh components Network group Particle components Rendering components Transform component UnityGUI group Wizards

Unity Components Audio components Implement sound in Unity Audio Listener Add this to a Camera to get 3D positional sound. Audio Source Add this Component to a GameObject to make it play a sound Audio Effects

Unity Components Physics components Physic Material Rigidbody Box Collider Capsule Collider Character Controller Character Joint Configurable Joint Constant Force Fixed Joint Hinge Joint Spring Joint Interactive Cloth Skinned Cloth

Unity Components The Game Object GameObjects are containers for all other Components All objects in your scene are inherently GameObjects They are containers that hold Components, which implement actual functionality. Ex. a Light is a Component which is attached to a GameObject.

Unity Components Mesh components 3D Meshes are the main graphics primitive of Unity Various components exist in Unity to render regular or skinned meshes, trails or 3D lines Mesh Filter Mesh Renderer Skinned Mesh Renderer Text Mesh

Unity Components Particle components Particle Systems are used to make effects Smoke Steam Fire Atmospheric effects Particle systems in Unity work by using one or two textures (2D), and drawing them many times, creating a chaotic random effect

Unity Components Particle components Ellipsoid Particle Emitter Line Renderer Mesh Particle Emitter Particle Animator Particle Renderer Trail Renderer Particle Collider

Unity Components Particle components Ellipsoid Particle Emitter spawns particles inside a sphere Use the Ellipsoid property to scale & stretch the sphere

Unity Components Particle components Line Renderer draws a straight line between two or more points in 3D space can be used to draw anything from a simple straight line, to a complex spiral renders billboard lines that have width and can be textured uses the same algorithm for line rendering as the Trail Renderer

Unity Components Particle components Trail Renderer makes trails behind moving objects in the scene

Unity Components Particle components Particle animator Move particles over time Used to apply wind, drag and color cycling to particle systems

Unity Components Particle components Mesh particle emitter emits particles around a mesh particles are spawned from the surface of the mesh

Particle component Open your Unity scene GameObject >Particle System Rename it Confetti

Particle component Particle Effect window / Inspector GameObject >Particle System

Particle component Open Particle Editor Adjust Size over Lifetime parameter in the graph view Adjust Color over Lifetime in the Editor

Particle component Create a script ParticleScript public var confettiemitter : ParticleSystem; function Start() { confettiemitter = GameObject.Find("Confetti").GetComponent(ParticleSyste m); } function Update() { if (Input.GetButtonDown("Fire1")) { confettiemitter.emit(30); //emits 30 particles } }

Particle component Assign ParticleScript to a cylinder (drag and drop) Assign Confetti Particles to Confetti Emitter Var in the Inspector (drag and drop from Hierarchy) Uncheck Play on Awake box in the Inspector With selected Confetti object in Hierarchy

Particle component Assign ParticleScript to a cylinder (drag and drop) Assign Confetti Particles to Confetti Emitter Var in the Inspector (drag and drop from Hierarchy)

Particle component Assign ParticleScript to a cylinder (drag and drop) Assign Confetti Particles to Confetti Emitter Var in the Inspector (drag and drop from Hierarchy)

Particle component Test the mouse button input and interaction The particle should emit 30 particles on mouse click

Interaction Key and Button input Add RigidBody component to the Cylinder In the Inspector

Interaction Key and Button input private var orange : Color = Color(0.8, 0.4, 0.0, 0.7); private var green : Color = Color(0.0, 0.9, 0.2, 0.7); var newmaterial : Material; var newmaterial2 : Material; function Update() { if (Input.GetButtonDown("Fire1")) { GetComponent.<Renderer>().material.color = orange; newmaterial.color = orange; } if (Input.GetButtonDown("Fire2")) { GetComponent.<Renderer>().material.color = green; newmaterial2.color = green; }}

Interaction Key and Button input Create addforcescript and assign it to the Cylinder Detects mouse clicks on an element #pragma strict function OnMouseDown () { GetComponent.<Rigidbody>().AddForce(transform.forward * 500f); } GetComponent.<Rigidbody>().useGravity = true;

Interaction Key and Button input Use ESC key to test mouse input and the Add Force function

Interaction Key and Button input Use ESC key to test mouse input and the Add Force function

Parenting Parent-Child Relationship in Unity The Child Game Object will inherit the behaviour of its parent It will move, rotate, scale exactly as its Parent does. Similar to Arm/Body rleationship- whenever your body moves, your arm moves along with it This is a way of grouping objects together Children can have their own children and etc. Complex parent-child structore Represented in the Hierarchy window

Parenting Drag and drop Confetti particles inside the Cylinder object in the Hierarchy window Test the game

Parenting Drag and drop Confetti particles inside the Cylinder object in the Hierarchy window Test the game

CAVE2 Interaction Wand / Wanda VR Input Devices The wand is the major input device used to interact with and control a virtual reality (VR) experience in the CAVE and other VR systems. It is essentially a 3D mouse, with a receiving antenna attached which provides the computer with information about the wand s position and orientation. buttons and a joystick

Interaction Wand / Wanda VR Input Devices The joystick is used primarily for navigation in combination with the position and orientation information. The buttons are used to set modes and select options.

Project Assets Assets are the models, textures, sounds and all other media files from which you make your 3D project Audio Files Materials Meshes Textures Prefabs Scripts Prefabs

Project Organization Project > Create >Folder

Project Organization Assets > Folder > Rename Materials Scripts Scenes Prefabs Textures Sounds

Prefabs Prefabs and reusable assets Create Prefab: Project > Create > Prefab Rename it PrefabSphere Game Object > 3D > Sphere Inspector : Add RigidBody Component Drag and drop sphere into PrefabSphere Delete Sphere n the Hierarchy window / scene

Prefabs

Prefabs

Prefabs

Prefabs Create InstantiateScript var prefabsphere : Transform; function Update () { if (Input.GetButtonDown("Jump")) { var instanceobject = Instantiate(prefabSphere, transform.position, transform.rotation); } }

Prefabs Assign script to FP character Controller (add one if your scene has no FPC) Assign prefabshpere to New Object in the Inspector Test the game ad press Space bar to instantiate spheres

Prefabs Assign script to FP character Controller (add one if your scene has no FPC) Assign prefabshpere to New Object in the Inspector Test the game ad press Space bar to instantiate spheres

Prefabs Assign script to FP character Controller (add one if your scene has no FPC) Assign prefabshpere to New Object in the Inspector Test the game and press Space bar to instantiate spheres during run-time

Instantiate 1. Which object to instantiate? the best way is to expose a variable We can state which object to instantiate by using drag and drop to assign a game object to this variable prefab 2 Where to instantiate it? create the new game object wherever the user (FPC) is currently located whenever the Jump button is pressed.

Instantiate Instantiate is to create objects during run-time (as the game is being played) Instantiate function takes three parameters; (1) the object we want to create (2) the 3D position of the object (3) the rotation of the object if (Input.GetButtonDown("Jump")) { var instanceobject = Instantiate(prefabSphere, transform.position, t ransform.rotation); }// the transform that the script is attached to (FP Character)

Instantiate To clean generated prefabs from the scene, attach the following script destroyprefabs to the prefabsphere var timeremaining = 3.0; function Update() { timeremaining -= Time.deltaTime; if (timeremaining <= 0.0) { Destroy(gameObject); } }

Instantiate To add a direction in which the prefabs are moving, Add a forward pointing force to the script: var forwardforce = 1000; instanceobject.getcomponent.<rigidbody>().addforce(transfor m.forward * forwardforce);

CAVE2 Unity Tutorial https://github.com/uic-evl/omicron-unity/wiki/cave2-unity-tutorial