Shooting in Unity3D (continued)

Similar documents
Creating Bullets in Unity3D (vers. 4.2)

Space Invadersesque 2D shooter

First Steps in Unity3D

Experiment 02 Interaction Objects

Learn Unity by Creating a 3D Multi-Level Platformer Game

PoolKit - For Unity.

Instructions for using Object Collection and Trigger mechanics in Unity

EVAC-CITY. Index. A starters guide to making a game like EVAC-CITY

Adding in 3D Models and Animations

Unity Game Development Essentials

Creating a First Person Shooter (FPS) Part 2

Section 39: BobmerMan How-To

COMPASS NAVIGATOR PRO QUICK START GUIDE

Foreword Thank you for purchasing the Motion Controller!

VACUUM MARAUDERS V1.0

Shoot It Game Template - 1. Tornado Bandits Studio Shoot It Game Template - Documentation.

Game Design Comp 150GD. Michael Shah 3/6/15

True bullet 1.03 manual

GAME:IT Junior Bouncing Ball

CMSC 425: Lecture 3 Introduction to Unity

Macquarie University Introductory Unity3D Workshop

TATAKAI TACTICAL BATTLE FX FOR UNITY & UNITY PRO OFFICIAL DOCUMENTATION. latest update: 4/12/2013

Unity 3.x. Game Development Essentials. Game development with C# and Javascript PUBLISHING

Workshop 4: Digital Media By Daniel Crippa

Pong Game. Intermediate. LPo v1

The purpose of this document is to outline the structure and tools that come with FPS Control.

Step 1 - Setting Up the Scene

Objectives: Create Sprites Create Sounds Create Objects Create Room Program simple game

Building Augmented Reality Spatial Audio Compositions for ios Introduction and Terms Spatial Audio Positioning

Module 4 Build a Game

By Chris Burton. User Manual v1.60.5

Heavy Station Kit base 2

GAME:IT Junior Bouncing Ball

GAME:IT Bouncing Ball

Save System for Realistic FPS Prefab. Copyright Pixel Crushers. All rights reserved. Realistic FPS Prefab Azuline Studios.

Click on the numbered steps below to learn how to record and save audio using Audacity.

Magic Leap Soundfield Audio Plugin user guide for Unity

Object Groups By Kyle Gillen (Last Updated 6/9/16)

SteamVR Unity Plugin Quickstart Guide

Meteor Game for Multimedia Fusion 1.5

The Beauty and Joy of Computing Lab Exercise 10: Shall we play a game? Objectives. Background (Pre-Lab Reading)

3D Top Down Shooter By Jonay Rosales González AKA Don Barks Gheist

Easy Input For Gear VR Documentation. Table of Contents

Tutorial: Creating maze games

Gesture Control FPS Horror/Survivor Game Third Year Project (COMP30040)

Kings! Card Swiping Decision Game Asset

Tutorial: A scrolling shooter

Beginning 3D Game Development with Unity:

Building Spatial Audio Compositions for Smartphones A Guide for Relative and Absolute Locative Audio Apps on ios and Android v 1.2

5.0 Events and Actions

DESIGN A SHOOTING STYLE GAME IN FLASH 8

PING. Table of Contents. PING GameMaker Studio Assignment CIS 125G 1. Lane Community College 2015

Physics For Javascript Games Animation And Simulations With Html5 Canvas

Game Maker Tutorial Creating Maze Games Written by Mark Overmars

For all question related to Photoshop that we cannot address in class, start by looking at the excellent Photoshop help: Help > Photoshop Help.

COMPUTING CURRICULUM TOOLKIT

Tasmanian Devil Model

Texas Hold Em Poker Unity Asset Store Project Multiplayer Version

TEMPLE OF LOCKS V1.0

Table of Contents. Creating Your First Project 4. Enhancing Your Slides 8. Adding Interactivity 12. Recording a Software Simulation 19

Once this function is called, it repeatedly does several things over and over, several times per second:

VR Easy Getting Started V1.3

Unity & VR Best Practices

PLANETOID PIONEERS: Creating a Level!

CONCEPTS EXPLAINED CONCEPTS (IN ORDER)

Unreal Studio Project Template

Slime VISIT FOR THE LATEST UPDATES, FORUMS & MORE ASSETS.

InfoSphere goes Android Angry Blob

C# Tutorial Fighter Jet Shooting Game

Live2D Mecanim = Expressiveness². Florian Andreas Gantzert

Installation Instructions

Game Design Document (GDD)

Star Defender. Section 1

No Evidence. What am I Testing? Expected Outcomes Testing Method Actual Outcome Action Required

Event Monitoring Setup

Beginner s Guide to Game Maker 4.3 Programming. Beginner s Guide to Game Maker 4.3 Programming

CISC 1600, Lab 2.2: More games in Scratch

Procedural Level Generation for a 2D Platformer

Recording your Voice Tutorials 3 - Basic Uses of Audacity Wayne B. Dickerson

GameMaker. Adrienne Decker School of Interactive Games and Media. RIT Center for Media, Arts, Games, Interaction & Creativity (MAGIC)

Moving Man Introduction Motion in 1 Direction

Ball Color Switch. Game document and tutorial

Control Systems in Unity

Creating Games with Game Maker: Inheritance, Variables, Conditionals. Prof. Jim Whitehead CMPS 80K, Winter 2006 Feb. 8, 2006

Students: Bar Uliel, Moran Nisan,Sapir Mordoch Supervisors: Yaron Honen,Boaz Sternfeld

Kismet Interface Overview

Learn how to. Link to Club Penguin. Link to Club Penguin. Link to Club Penguin. Movie Clip

Crowd-steering behaviors Using the Fame Crowd Simulation API to manage crowds Exploring ANT-Op to create more goal-directed crowds

Cannon Ball User Manual

Shader "Custom/ShaderTest" { Properties { _Color ("Color", Color) = (1,1,1,1) _MainTex ("Albedo (RGB)", 2D) = "white" { _Glossiness ("Smoothness", Ran

VOCAL FX PROJECT LESSON 9 TUTORIAL ACTIVITY

unity 3d and playmaker pdf Unity 3D and PlayMaker Essentials: Game Development from Practical Game Design with Unity and Playmaker - pdf

Words Mobile Ready Game Documentation

Hoboken Public Schools. High School Media Production Curriculum

USER MANUAL v1.2.1 Please read this manual carefully before using the software. Using headphones requires responsible listening!

3.4 COLOR CORRECTION

AIM OF THE GAME GLACIER RACE. Glacier Race. Ben Gems: 20. Laura Gems: 13

Solving Usability Problems in Video Games with User Input Heuristics

Objects in Alice: Positioning and. Moving Them July 2008

BE SURE TO COMPLETE HYPOTHESIS STATEMENTS FOR EACH STAGE. ( ) DO NOT USE THE TEST BUTTON IN THIS ACTIVITY UNTIL THE END!

Transcription:

AD41700 Computer Games Prof. Fabian Winkler Fall 2011 Shooting in Unity3D (continued) In this tutorial I would like to continue where we left off in the Shooting tutorial. Specifically I would like to introduce a script that detects if you have hit something with your bullet or not. I added two more cubes to the previous scene the red one called stand, the turquoise one called top_cube. Both new game objects have rigid body components added to them. The idea is that when one of the bullets is hitting them that they would fall to the floor. You can already try it out and see the physics engine is at work: Winkler, Scripting, Counters and GUI workshop, p. 1

Next we would like to detect the collision between the bullet and the red stand, so I wrote the following script ( collisionscript ) using Unity s built-in OnCollisionEnter function: I attach this script to the bullet prefab. When you shoot at the red stand and hit it you should see Hit! in the status bar at the bottom of the scene window. Let s trigger a sound this time when we hit the stand. I prepared a sound file called bang.aiff (remember Unity only likes uncompressed sound -.aiff or.wav or ogg/vobis. Import the sound file into your Project window: Asset > New Asset Next, select it and in the Inspector check off the 3D sound option and hit Apply. I change the collisionscript to include two lines that trigger the audio playback: var mysound : AudioClip; audio.playoneshot(mysound); Don t forget to drag and drop the sound asset onto the variable mysound in the Inspector after selecting the prefab, so the correct sound is assigned to the script. Finally, Component > Audio > AudioSource In the Inspector, choose bang as the Audio Clip and uncheck Play On Awake : Winkler, Scripting, Counters and GUI workshop, p. 2

Try it out and see what happens. Every time the cube bullet hits the red stand the bang sound is triggered. To only trigger it once we change the script slightly and introduce a variable that keeps track if the sound has already played: var mysound : AudioClip; var istriggered = false; if (istriggered == false) audio.playoneshot(mysound); istriggered = true; Housecleaning Now that we know how to create game objects dynamically at runtime it is a good idea to think about removing them eventually as well. With the scripting experience you have gained so far you can figure out different events that might remove the cube bullets from your scene (e.g. when they collide with another game object), in the following script ( destroy_bullets ), I use a timer that automatically removes (destroys) the game objects after a certain amount of time: Winkler, Scripting, Counters and GUI workshop, p. 3

var timeremaining = 3.0; function Update() timeremaining -= Time.deltaTime; if (timeremaining <= 0.0) Destroy(gameObject); Simply attach this script to the bullet prefab and watch the cubes disappear after 3 seconds. Hit Counter with Onscreen Text In the next step I would like to setup a counter that counts the number of hits and displays them as onscreen text. First I create a GUI text game object: Game Object > Create Other > GUI Text I name this new game object GUI_counter Then I create a script called GUItext_script which controls the text of the GUI and also the text color: var hitcounter = 0; var color : Color = Color(0.8, 0.7, 0.0, 1.0); // orange/fully opaque function Start() guitext.material.color = color; function Update() guitext.text ="Number of Hits: "+ hitcounter; This script is attached to the GUI_counter game object in the Hierarchy window (just drag and drop it onto GUI_counter Winkler, Scripting, Counters and GUI workshop, p. 4

Because I would like to update the hitcounter variable in the GUItext_script from within the collisionscript I need to add a couple of line of code to collisionscript : var mysound : AudioClip; var istriggered = false; var hitcounter = 0; private var otherscript : GUItext_script; function Awake() otherscript = GameObject.Find("GUI_counter").GetComponent(GUItext_script); if (istriggered == false) audio.playoneshot(mysound); otherscript.hitcounter++; istriggered = true; The Awake() function initializes the variable otherscript with a reference to the script GUItext_script which is attached to the GUI_counter game object. Winkler, Scripting, Counters and GUI workshop, p. 5

You can now hit the play button and start counting how many times you have hit the target: Winkler, Scripting, Counters and GUI workshop, p. 6