Week 6: Time and triggers!

Slides:



Advertisements
Similar presentations
Introduction to Macromedia Director 8.5 – Lingo
Advertisements

Microsoft® Small Basic
Events Chapter 7. Interactivity The real world is interactive User determines order of actions instead of programmer.
Events Chapter 7. Interactive Real world is interactive User determines order of actions instead of programmer.
Cosc 5/4730 Game Design. A short game design primer. A game or animation is built on an animation loop. – Instance variables of “objects” are updated.
UFCFSU-30-13D Technologies for the Web Creating and Using GUI Components.
A graphical user interface (GUI) is a pictorial interface to a program. A good GUI can make programs easier to use by providing them with a consistent.
Cosc 5/4730 Game Design. A short game design primer. A game or animation is built on an animation loop. – Instance variables of “objects” are updated.
HELLO WORLD: YOUR FIRST PROGRAM CHAPTER Topics  Hello World?  Creating a Unity Project –The Unity Project Folder  MonoDevelop: Unity's Code Editor.
Software design and development Marcus Hunt. Application and limits of procedural programming Procedural programming is a powerful language, typically.
GAME:IT Junior Bouncing Ball Objectives: Create Sprites Create Sounds Create Objects Create Room Program simple game.
Game Design Creating a game called PING Phase 3: Steps for building basic game.
EEC-693/793 Applied Computer Vision with Depth Cameras Lecture 13 Wenbing Zhao
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Checking for Collisions: Alternative Method Erin Taylor Under the Direction of Susan Rodger July 2015 Duke University.
SE 320 – Introduction to Game Development Lecture 8: Animations, GUIs, Debugging and IDEs Lecturer: Gazihan Alankuş Please look at the last two slides.
Getting a handle on ActionScript A basic primer for non-programmers.
UFCFS D Technologies for the Web Unity 3D: Review of Topics and Related Concepts.
Fundamentals of GUI Programming. Objectives: At the end of the session, you should be able to: describe the guidelines that are used for creating user-friendly.
11 Adding Tomato Targets Session Session Overview  We now have a game which lets a player bounce a piece of cheese on a bread bat  Now we have.
Learning Unity. Getting Unity
Microsoft® Small Basic Collision Detection Estimated time to complete this lesson: 1 hour.
Game Maker Terminology
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.
Grade Book Database Presentation Jeanne Winstead CINS 137.
Topics Introduction Scene Graphs
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 – Graphical User Interfaces Java Foundations: Introduction to Programming.
Unity GUI Creating and Using GUI Components. Agenda GUI Components GUI Layout Using Styles and Skins for Design ‘Look and Feel’ Scripting GUI Communication.
Problem Solving Methodology Rachel Gauci. Problem Solving Methodology Development Design Analysis Evaluation Solution requirements and constraints. Scope.
Lesson 2: Reading a program. Remember: from yesterday We learned about… Precise language is needed to program Actors and Classes Methods – step by step.
Programming Games Show your rock-paper-scissors. Demonstrate bouncing ball. Demonstrate and examine Bo the dog. Homework: Modify Bo to make your own.
SCRIPT PROGRAMMING WITH FLASH Introductory Level 1.
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.
Understanding JavaScript and Coding Essentials Lesson 8.
Expressive Intelligence Studio // Center for Games and Playable Media // Unity Pro John Murray Expressive.
 How can we find/refer to objects at runtime?  This must be dynamic because objects may come and go.  How can we solve this problem?
Lesson Seven: Using Flags. What Are Flags? Flags are Variables or Switches Used to Help With Logic Control of your character. Normally, Flags are used.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
Game Development with Unity3D
Section 10.1 Define scripting
Unit 2 Technology Systems
EEC-693/793 Applied Computer Vision with Depth Cameras
Quick Intro to Unity Lecture 2.
MORE Genre Specific Physics
Game Development with Unity3D Inside/Outside Unity3D
2D Graphics and Animations in Unity 3D
Unity 2D: Step by Step, Part 4
A First Look at GUI Applications
EEC-693/793 Applied Computer Vision with Depth Cameras
Understanding an App’s Architecture
Let's Race! Typing on the Home Row
Chap 7. Building Java Graphical User Interfaces
EEC-693/793 Applied Computer Vision with Depth Cameras
Graphical User Interfaces -- Introduction
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Learning Objective LO: We’re learning to understand when it is appropriate to use particular data types.
Create a Simple UI Game in 10 Steps
ROOM 2+ FEATURES A-CREEPIN’ BEFORE WE START: LANYARDS RECAP ALL HERE?
Data Collections, Loops, Instantiation and some pieces that fell off.
Fundaments of Game Design
Fundaments of Game Design
Tonga Institute of Higher Education
EEC-693/793 Applied Computer Vision with Depth Cameras
Deeper into the Depths: Casting, Scope, Gizmos, Layers, Self-Destruct.
Unity Game Development
CIS125GA_03 Things that help
Unity Game Development
CIS125GA Week 4 Logical Beginnings
Presentation transcript:

Week 6: Time and triggers!

Contents 13 Slides Update/ Fixed update Time / Delta Time Basic Controller Collision Triggers Tags RigidBodies Basic Movement Old UI / New UI Boolean Toggle

Update/ Fixed update SO far we’ve been using “Update” which calculated everything frame by frame. Every frame, update checks the state of everything, such as button pushes, collision, scores and variables, and responds with the correct methods, animations, and placement of every Game Object within the scene. But sometimes, we have more complicated scenes, with a LOT more calculations, such as giant particle explosions, weather effects, or hundreds of moving assets on screen. Since these frames with all the extra action take longer to calculate, they also take longer to update, causing the game to have some strange, slow-mo parts. We can smooth this out by using the built – in FixedUpdate(), which runs on on a predefined number of frames per second, instead of “all the frames we can calculate per second.” This is especially used when we have RIGIDBODIES in our scene.

Time / Delta Time Since game engines think in frame rates, if we want it to use a real time, we have to specify that’s what we want. We do this by using Time.deltaTime If we want to make a timer, we have to use a FLOAT! EX: public float timeLeft = 25f; timeLeft -= Time.deltaTime;

Basic Character Controller Now that you can use Time.deltaTime, you can move things over the span of several frames! We will make a very basic controller, that looks for keyboard input and either tranfroms.Translate or transform.Rotate over time. EX: public GameObject MyCar; MyCar.transform.Translate (Vector3.forward * PlayerSpeed * 10 * Time.deltaTime);

Collision In order for objects to appear solid in a game engine, we need COLLISION! In most engines, this is made by generating simple shapes such as a cube, around the model, and checking (every frame) if anything has intersected the colliders bounds and does something based on that information. In Unity, you can use a variety of COLLIDERS, from the humble, simple box (faster calculations) to an exact replica of your model ( more visually accurate collision, but much more calculation heavy) and several primitives (simple shapes) in between. Once the collision has been detected, we can run code, such as “remove HP” or “end game!” Select object --> Component --> physics --> pick collider shape

Triggers TRIGGERS: if you would like your collision box to instead work as a trigger, You can tick the IsTrigger Boolean checkbox in the Collider Component section of the inspector: You can use code to define an event to happen when the object enters the triggers space, (Occurs once) When it is staying in it, (Occurs continuously) or when it exits (occurs once).

Tags TAGS let you add a BULK NAME to any gameobjects, allowing you address many different things as a group. Examples Might be “ENEMY” or “DESTROYABLE”. A Tag is a STRING owned by that object, and is addressed as such. From there, you can also check the name or tag of the triggering object, to define what reaction you would like. if (other.gameObject.name == "LapGate") { Do these Instructions ;} Tags can be things like enemies, power ups, cabbages, players, push-able cubes, etc.

RigidBodies If you would like the object to react to built in physics calculations, you also need to add a Rigidbody . RigidBodies have several Important options: Use Gravity: Controls whether gravity affects this Rigidbody. Is Kinematic: Controls whether physics affects the Rigidbody. They are added in the same fashion as collision: Select object --> Component --> Physics --> RigidBody

Destroy() MWAHAHAHAHAHAHA Destroy is a special built-in function, that removes an object from both the SCENE and from MEMORY. This is especially helpful in situations where we instantiate a lot of models, such as bullets. Required arguments are “ What should we destroy?” Example: Destroy ( other.gameObject);

NEW UI As of Unity 4.6, Unity has implemented a new system for creating GUI’s. Now, Unity uses a Flash-like, WYSIWYG interface. It begins with a CANVAS object that acts like a 2D piece of cellophane taped to your camera, or placed in your level. Then, UI objects are placed on that cellophane. An EVENT SYSTEM can call different methods based on interaction with those objects, such as a button click. UI Object types include Buttons, Sliders, Labels, Panels, Scrollbars, and Interactive Input Fields the player can type in. To use Unity UI, add the library at the top of your script: using UnityEngine.UI;

Old UI To add to our interactivity, let’s make a start button! The start button is part of the built in OnGUI method, so we need to include it there, BUT it also includes an IF statement! The button, by it’s very nature, already knows that it uses a click event, so we do not need to give it that information. Also, since the button is part of an if statement (A question!), it is no longer an instruction, and does not get a semicolon! void OnGUI () { if ((GUI.Button (new Rect (700, 2, 100, 100), “Text on the button"))) // Do These Instructions; }

Boolean Toggle You can use programming shorthand to create a Boolean toggle, changing true to false, and false to true: Bool = !Bool ; This is short hand for:   If (bool == true) { bool = false; } Else bool = true;