Basic Unity Scripting/Programming & Components

Slides:



Advertisements
Similar presentations
INTRODUCTION TO ADOBE FLASH CS4
Advertisements

Introduction Games have always been a fundamental part of human life. Space storm “ عاصفة الفضاء” is a 3D SCI-FI game that consists of two stages presented.
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Macromedia Director 8 Foundation Level Course. What is Director? Director is a challenging program for creating animation and multimedia productions for.
Week 11 - Wednesday.  Image based effects  Skyboxes  Lightfields  Sprites  Billboards  Particle systems.
SE 313 – Computer Graphics Lecture 13: Lighting and Materials Practice Lecturer: Gazihan Alankuş 1.
Working with 3Ds Max. 3Ds Max.
Chapter 5 Develop a PSA & Commercial Using Premiere Pro & After Effects CS6.
Multimedia for the Web: Creating Digital Excitement Multimedia Element -- Graphics.
AGD: 5. Game Arch.1 Objective o to discuss some of the main game architecture elements, rendering, and the game loop Animation and Games Development.
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 19 Other Graphics Considerations Review.
Creative Commons Attribution 3.0 creativecommons.org/licenses/by/3.0 Key Abstractions in Game Maker Foundations of Interactive Game Design Prof. Jim Whitehead.
What is Director?  A tool for creating interactive CDs or interactive media and games on the Web.  Combines graphics, sound, video and other media together.
BUILDING RICH MEDIA ELEMENTS. Design Decisions Based on Design Specification  Following the design specification will ensure that the application is.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
CS324e - Elements of Graphics and Visualization Checkerboard World.
London April 2005 London April 2005 Creating Eyeblaster Ads The Rich Media Platform The Rich Media Platform Eyeblaster.
Advanced Level Course. Site Extras Site Extras consist of four categories: Stationeries Site Trash Designs Components.
Chapter 8: Writing Graphical User Interfaces
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
© 2012 Adobe Systems Incorporated. All Rights Reserved. Copyright 2012 Adobe Systems Incorporated. All rights reserved. ® INTRODUCTION TO FLASH ANIMATION.
® Copyright 2010 Adobe Systems Incorporated. All rights reserved. ® ® 1 INTRODUCTION TO ADOBE FLASH PROFESSIONAL CS5.
Rendering. Rendering is the process of computing frames of video and sections of audio so that they can be played smoothly in Final Cut Pro. Once rendered,
CHAPTER TEN AUTHORING.
Web Games Programming An Introduction to Unity 3D.
UFCFS D Technologies for the Web Unity 3D: Review of Topics and Related Concepts.
1. Press the New Layer Button 3. Double click names to re-name Ball & Shadow layers 2. Click to change to 12 fps Step 1.
Learning Unity. Getting Unity
Introduction to Flash Animation CS 318. Topics Introduction to Flash and animation The Flash development environment Creating Flash animations  Layers.
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.
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
Exploring the Macromedia Flash Workspace – Lesson 2 1 Exploring the Macromedia Flash Workspace Lesson 2.
Yingcai Xiao Game Development with Unity3D. Outline IDE Engine Assets Tutorial Examples Inside.
UFCEK-20-3Web Games Programming Unity 3D: Review of Topics Publishing for the Web.
Point Sprites Course Information CVG: Programming 4 My Name: Mark Walsh Website: Recommended.
Introduction to Interactive Media Interactive Media Tools: Authoring Applications.
Reading Flash. Training target: Read the following reading materials and use the reading skills mentioned in the passages above. You may also choose some.
“The primary purpose of cinematic lighting is to support the story by contributing to the overall visual structure of the film.” From Advanced Renderman.
Photoshop Actions Lights, Camera, Actions in Photoshop.
Copyright © Texas Education Agency, All rights reserved.1 Web Technologies Motion Graphics & Animation.
XP Tutorial 3 Creating Animations. XP New Perspectives on Macromedia Flash MX Elements of Animation Layers are used to organize the content of.
UFCFSU-30-13D Technologies for the Web An Introduction to Unity 3D.
Expressive Intelligence Studio // Center for Games and Playable Media // Unity Pro John Murray Expressive.
Yingcai Xiao Game Development with Unity3D Inside/Outside Unity3D.
Game Development with Unity3D
Unity 3D Rolfe Bozier 24-Apr-2017
EEC-693/793 Applied Computer Vision with Depth Cameras
Quick Intro to Unity Lecture 2.
Reading and Writing Image Files
Game Development with Unity3D Inside/Outside Unity3D
Layers in Adobe After Effect
3GB3 Game Design Unity 3D Basics.
More (C#) Scripting Day 2, Lesson 1.
2D Graphics and Animations in Unity 3D
EEC-693/793 Applied Computer Vision with Depth Cameras
Week 11 - Wednesday CS361.
Game Development Unity3D.
Austin Grosel & Aaron Ebbinghaus
EEC-693/793 Applied Computer Vision with Depth Cameras
INTRODUCTION TO ADOBE FLASH CS4
.NET and .NET Core 7. XAML Pan Wuming 2017.
Working with 3Ds Max. 3Ds Max.
A Prime Example of HCI Application
UMBC Graphics for Games
Week 6: Time and triggers!
EEC-693/793 Applied Computer Vision with Depth Cameras
Unity Game Development
Presentation transcript:

Basic Unity Scripting/Programming & Components

Scripting/programming

Scripting Overview Scripting inside Unity consists of attaching custom script objects called behaviors to game objects. In C#, subclass MonoBehaviour (note spelling) to implement behaviors. Different functions inside the script objects are called for certain events.

Scripting Overview Scripting inside Unity consists of attaching custom script objects called behaviors to game objects. To make this association, simply drag the script from the Project window to the object in the Hierarchy window. (If a dialog appears that says “Losing prefab” then choose “continue.”)

Scripting Overview Different functions inside the script objects are called on certain events. Most frequently used (overridden): void Update ( ) This function is called before rendering a frame. This is where most game behavior code goes, except physics code. void FixedUpdate ( ) This function is called once for every physics time step. This is the place to do physics-based game behavior. You can also define (override) event handlers. These all have names starting with On, (i.e. OnCollisionEnter). See MonoBehaviour class documentation.

Basic C# Script using UnityEngine; using System.Collections; public class NewBehaviourScript : MonoBehaviour { // Use this for initialization void Start ( ) { } // Update is called once per frame void Update ( ) { NewBehaviourScript is a subclass of MonoBehaviour. Class name, NewBehaviourScript, must match file name, NewBehaviourScript.cs.

Don’t use ctors! “Using the constructor when the class inherits from MonoBehaviour, will make the constructor to be called at unwanted times and in many cases might cause Unity to crash.” http://unity3d.com/support/documentation/ScriptReference/index.Writing_Scripts_in_Csharp.html

Basic C# Script using UnityEngine; using System.Collections; public class NewBehaviourScript : MonoBehaviour { public Vector3 something; // Use this for initialization void Start ( ) { } // Update is called once per frame void Update ( ) { Public member variables will appear in the Unity UI (once an associate between the script and an object has been made). Private, protected, and public const do not.

Components (http://unity3d. com/support/documentation/Components/index

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

Animation Components Animation Animation Clip stores all animation data that can be used for animated characters or simple animations

Asset Components Assets are the models, textures, sounds and all other “content” files from which you make your game. Audio Clip Cubemap Texture Flare Font Material Meshes Movie Texture Render Texture Text Asset Texture 2D

Audio Components These 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 (PRO only)

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

Physics Components Unity uses the PhysX engine from nvidia. See http://www.nvidia.com/object/physx_new.html for demos, and http://developer.nvidia.com/object/physx.html for developers info.

The GameObject GameObjects are containers for all other Components. All objects in your game are inherently GameObjects. GameObjects do not add any characteristics to the game by themselves. They are containers that hold Components, which implement actual functionality. For example, a Light is a Component which is attached to a GameObject. an empty game object

Image Effect Scripts This group handles all Render Texture-based fullscreen image postprocessing effects. They add a lot to the look and feel of your game without spending much time on artwork. But they are only available with Unity Pro!

Image Effect Scripts Blur image effect Bloom and flares image effect Color correction curves image effect Color correction image effect Contrast enhance image effect Contrast stretch image effect Crease image effect Depth of field image effect Edge blur image effect Edge detection image effect Edge detect normals image effect Fisheye image effect Glow image effect Grayscale image effect Motion blur image effect Noise image effect Sepia tone image effect Screen Space Ambient Occlusion (SSAO) image effect Sun shafts image effect Twirl image effect Vignetting image Effect Vortex image effect

Settings Managers Audio Manager Input Manager Network Manager Physics Manager Player Settings Quality Settings Render Settings Tag Manager Time Manager Most can be accessed via Edit  Project Settings  <manager>.

Settings Managers Audio Manager

Settings Managers Input Manager

Settings Managers Network Manager

Settings Managers Physics Manager

Settings Managers Player Settings Player Settings is where you define various parameters (platform specific) for the final game that you will build in Unity.

Settings Managers Quality Settings

Settings Managers Render Settings fog off (right), and fog on (below)

Settings Managers Tag Manager The Tag Manager allows you to set up Layers and Tags (Edit->Project Settings->Tags). Tags are used to quickly find objects from scripts, utilizing the Tag name. Layers can be used to cast rays, render, or apply lighting to certain groups of objects only.

Settings Managers Time Manager Fixed Timestep Maximum Allowed Timestep A framerate-independent interval that dictates when physics calculations and FixedUpdate() events are performed. Maximum Allowed Timestep A framerate-independent interval that caps the worst case scenario when frame-rate is low. Physics calculations and FixedUpdate() events will not be performed for longer time than specified. Time Scale The speed at which time progress. Change this value to simulate bullet-time effects. A value of 1 means real-time. A value of .5 means half speed; a value of 2 is double speed.

(End settings managers – back to 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

Network Group Network View Network Views are the gateway to creating networked multiplayer games in Unity. They are simple to use, but they are extremely powerful. You can learn and discover the fundamental concepts in the Network Reference Guide.

Particle Components Particle Systems are used to make clouds of smoke, steam, fire and other atmospheric effects. Particle systems in Unity work by using one or two textures, and drawing them many times, creating a chaotic effect. They are 2D in Unity.

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

Particle Components Ellipsoid Particle Emitter The Ellipsoid Particle Emitter spawns particles inside a sphere. Use the Ellipsoid property below to scale & stretch the sphere.

Particle Components Line Renderer The Line Renderer takes an array of two or more points in 3D space and draws a straight line between each one. A single Line Renderer Component can thus be used to draw anything from a simple straight line, to a complex spiral. The line is always continuous; if you need to draw two or more completely separate lines, you should use multiple GameObjects, each with its own Line Renderer. The Line Renderer does not render one pixel thin lines. It renders billboard lines that have width and can be textured. It uses the same algorithm for line rendering as the Trail Renderer.

Particle Components Mesh Particle Emitter The Mesh Particle Emitter emits particles around a mesh. Particles are spawned from the surface of the mesh, which can be necessary when you want to make your particles interact in a complex way with objects.

Particle Components Particle Animator Particle Animators move your particles over time, you use them to apply wind, drag & color cycling to your particle systems.

Particle Components Particle Renderer The Particle Renderer renders the Particle System on screen.

Particle Components Trail Renderer The Trail Renderer is used to make trails behind objects in the scene as they move about.

Particle Components Particle Collider The World Particle Collider is used to collide particles against other Colliders in the scene.

Particle Components Once again, they are 2D in Unity. See http://www.youtube.com/view_play_list?p=55C1A52A917B2DDF for examples of 3D particle systems. Also see http://software.intel.com/en-us/articles/tickertape/ for Intel’s parallel 3D particle systems (2 videos: demo and discussion).

Rendering Components This group contains all Components that have to do with rendering in-game and user interface elements. Lighting and special effects are also included in this group. Camera Flare Layer GUI Layer GUI Text GUI Texture Halo Halo Layer Lens Flare Light Lightmapping Projector Skybox

Rendering Components Camera Cameras are the devices that capture and display the world to the player. By customizing and manipulating cameras, you can make the presentation of your game truly unique. You can have an unlimited number of cameras in a scene. They can be set to render in any order, at any place on the screen, or only certain parts of the screen.

Rendering Components Camera Two-player display created with Normalized Viewport Rectangle

Rendering Components Camera perspective (left) and orthographic/parallel (right)

Rendering Components Camera Render texture This feature is only available for Unity Advanced licenses. It will place the camera's view onto a Texture that can then be applied to another object. This makes it easy to create sports arena video monitors, surveillance cameras, reflections etc. A Render Texture used to create a live arena-cam below.

Rendering Components Flare Layer The Flare Layer Component can be attached to Cameras to make Lens Flares appear in the image. By default, Cameras have a Flare Layer already attached.

Rendering Components GUI Layer A GUI Layer Component is attached to a Camera to enable rendering of 2D GUIs. When a GUI Layer is attached to a Camera it will render all GUI Textures and GUI Texts in the scene. GUI Layers do not affect UnityGUI in any way. You can enable and disable rendering GUI in a single camera by clicking on the check box of the GUI Layer in the Inspector.

Rendering Components GUI Text GUI Text displays text of any font you import in screen coordinates.

Rendering Components GUI Texture GUI Textures are displayed as flat images in 2D. They are made especially for user interface elements, buttons, or decorations. Their positioning and scaling is performed along the x and y axes only, and they are measured in Screen Coordinates, rather than World Coordinates.

Rendering Components Halo Halos are light areas around light sources, used to give the impression of small dust particles in the air.

Rendering Components Halo Layer The Halo Layer can be attached to Cameras to make Halo objects appear in the image. It has no properties of its own.

Rendering Components Lens Flare Lens Flares simulate the effect of lights refracting inside camera lens. They are used to represent really bright lights or, more subtly, just to add a bit more atmosphere to your scene.

Rendering Components Light Lights will bring personality and flavor to your game. You use lights to illuminate the scenes and objects to create the perfect visual mood. Lights can be used to simulate the sun, burning match light, flashlights, gun-fire, or explosions, just to name a few.

Rendering Components Light ex. point light

Rendering Components Light Point lights can have cookies (i.e., a cubemap texture with alpha channel). This Cubemap gets projected out in all directions.

Rendering Components Light Spot lights only shine in one direction, in a cone. They are perfect for flashlights, car headlights or lamp posts. They are the most expensive on the graphics processor.

Rendering Components Light Spot lights can also have cookies - a texture projected down the cone of the light. This is good for creating an effect of light shining through the window.

Rendering Components Light Directional lights are used mainly in outdoor scenes for sun & moonlight. The light affect all surfaces of objects in your scene. They are the least expensive on the graphics processor.

Rendering Components Light Directional Light projecting a cloud-like cookie texture. A cookie is a great way to add some quick detail to large outdoor scenes. You can even slide the light slowly over the scene to give the impression of moving clouds.

Rendering Components Lightmapping Advanced features such as bumpmapping and “baked in” or realtime shadows.

Rendering Components Projector Projectors allow you to project an arbitrary Material on all objects that intersect its frustum. A Projector is used to create a Blob Shadow for this Robot (below).

Rendering Components Skybox Skyboxes are a wrapper around your entire scene that display the vast beyond of your world.

Transform Component This group is for all Components that handle object positioning outside of Physics. Transform

UnityGUI Group UnityGUI is the GUI creation system built into Unity. It consists of creating different Controls, and defining the content and appearance of those controls. GUI Skin GUISkins are a collection of GUIStyles that can be applied to your GUI. Each Control type has its own Style definition. Skins are intended to allow you to apply style to an entire UI, instead of a single Control by itself. GUI Style GUI Styles are a collection of custom attributes for use with UnityGUI. A single GUI Style defines the appearance of a single UnityGUI Control.

Wizards Unity has a simple wizard that lets you create your own ragdoll in no time. You simply have to drag the different limbs on the respective properties in the wizard. Then select create and Unity will automatically generate all Colliders, Rigidbodies and Joints that make up the Ragdoll for you. Ragdoll Wizard