Lecture 2 Richard Gesick

Slides:



Advertisements
Similar presentations
Principles of Web Design 5 th Edition Chapter Nine Site Navigation.
Advertisements

Events Chapter 7. Interactive Real world is interactive User determines order of actions instead of programmer.
COMPUTER PROGRAMMING 2 Chapter 7 Sound. Objectives Find out how to prepare sounds for inclusion in Microsoft XNA projects. Incorporate sounds into XNA.
© by Pearson Education, Inc. All Rights Reserved.
Visual Basic 2010 How to Program. © by Pearson Education, Inc. All Rights Reserved.2.
3D Game Programming All in One By Kenneth C. Finney.
Windows 10. The New Microsoft Operating System to be released July 29 th. It’s not just a PC operating system, it’s a lot more, it includes phones,
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Introduction to Scratch!
© 2011 Delmar, Cengage Learning Chapter 9 Introduction to ActionScript 3.0.
Developing the Game User Interface (UI) Lesson 5.
Domain 3 Understanding the Adobe Dreamweaver CS5 Interface.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
Chapter 8 Collecting Data with Forms. Chapter 8 Lessons Introduction 1.Plan and create a form 2.Edit and format a form 3.Work with form objects 4.Test.
By Melissa Dalis Professor Susan Rodger Duke University June 2011 Multiplication Table.
Chapter 10 Function Block Diagram
11 Getting Player Input Using a Gamepad Session 3.1.
Practical Programming COMP153-08S Week 5 Lecture 1: Screen Design Subroutines and Functions.
Principles of Web Design 6 th Edition Chapter 9 – Site Navigation.
CHAPTER 3 Getting Player Input XNA Game Studio 4.0.
Envision Tutorial Horner APG, LLC July 18, Introduction The Cscape Remote Viewer allows remote interaction with the user interface on Horner OCS.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Events Programming with Alice and Java First Edition by John Lewis.
VB.NET and Databases. ADO.NET VB.Net allows you many ways to connect to a database. The technology used to interact with a database or data source is.
Explore GNOME The easy way, using a live CD By Carl Weisheit.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
Pasewark & Pasewark 1 Windows Vista Lesson 1 Windows Vista Basics Microsoft Office 2007: Introductory.
Lecture Input Devices Keyboard. Mouse Microphone Digital Camera Scanner.
Review for Final June 13, 2016.
Scratch Programming Cards
Dive Into® Visual Basic 2010 Express
By Melissa Dalis Professor Susan Rodger Duke University June 2011
Chapter 5 Validating Form Data with JavaScript
EEC-693/793 Applied Computer Vision with Depth Cameras
Using the Cyton Viewer Intro to the viewer.
Topic 02: Introduction to ActionScript 3.0
Collision Theory and Logic
CS 134 Alternate Inputs.
Scratch for Interactivity
EEC-693/793 Applied Computer Vision with Depth Cameras
Collision Theory and Logic
Comparing objects and changing color
Keyboard Input.
Graphing Linear Equations
Mobile Navigation Control for Planetary Web Portals Team Members: John Calilung, Miguel Martinez, Frank Navarrete, Kevin Parton, Max Ru, Catherine Suh.
Toolbars and Status Bars
Chapter 3 Working With Unity
Computer Programming I
Program and Graphical User Interface Design
Chapter 3 Graphing.
Let's Race! Typing on the Home Row
Introduction to Events
More on Graphical User Interfaces
EEC-693/793 Applied Computer Vision with Depth Cameras
Program and Graphical User Interface Design
Inventory ch 4 Richard Gesick.
Predefined Dialog Boxes
Granting support access for individuals to Bill to IDs
Granting support access for individuals to contracts
Introduction to TouchDevelop
UNITY TEAM PROJECT TOPICS: [1]. Unity Collaborate
Re-enabling Cisco’s ability to associate individuals to a Bill to ID
Week 6: Time and triggers!
Programming Lists of Data 靜宜大學資管系 楊子青
Fundaments of Game Design
Fundaments of Game Design
EEC-693/793 Applied Computer Vision with Depth Cameras
Unity Game Development
Catch Game Cards Catch Game Cards Make a Card Go to the Top Fall Down
Presentation transcript:

Lecture 2 Richard Gesick Interactive Input ch 1 Lecture 2 Richard Gesick

Objectives Creating controls for the Xbox 360 Controller Creating controls for a keyboard Writing a function to detect whether our controller device is plugged in Customizing our controls Letting players switch controls Switching controls with Graphical User Interface (GUI) buttons Resetting controls back to factory settings

Controllers the keyboard/mouse Xbox 360 Controller Ability to switch between the profiles and customize control configurations

Mapping the needed controls Action Keyboard/mouse Xbox 360 Controller Movement WASD keys Left thumbstick Rotate camera Mouse Right thumbstick Item bar buttons 1234 keys Directional pad Inventory The I key The A button Pause game The Esc key The Start button Attack/use an item left mouse button The left trigger Aim right mouse button The right trigger

Checking the Xbox 360 Controller inputs

Adding additional controller inputs To get started, access your input manager by navigating to the Edit menu, hovering over Project Settings, and clicking on Input. Open up the Axes dropdown by clicking on the arrow next to it and change the number in the Size parameter to be a value higher. This will add another input at the bottom of the list, which we can use for one of our types of inputs. By default, by creating a new type of input, the input manager duplicates the bottom input. So open it and we'll make our changes. Follow these steps to create our new input: Change the value of the Name parameter to A_360. Change the value of the Positive Button parameter to joystick button 0.

Adding a start button and trigger inputs 1. Change the value of the Name parameter to Triggers_360. 2. Change the value of the Sensitivity parameter to 0.001. 3. Check the Invert parameter. 4. Change the value of the Type parameter to Joystick Axis. 5. Change the value of the Axis parameter to 3rd Axis (Joysticks and Scrollwheel).

Adding directional pad inputs Change the value of the Name parameter to HorizDpad_360. Change the value of the Sensitivity parameter to 1. Change the value of the Type parameter to Joystick Axis. Change the value of the Axis parameter to 6th Axis (Joysticks). For the vertical directional pad input, you can follow the exact same steps as we did for the horizontal directional pad input; just change the value of Name to VertDpad_360 and change the value of Axis to 7th Axis (Joysticks). This completes the Xbox 360 Controller inputs; all that's left are the PC inputs.

Adding PC control inputs Most of our PC control inputs are already integrated into the input manager; all that is left are the number keys, I key, and Esc key. You can actually follow the same steps as at the beginning of this chapter, when we added the Xbox 360 buttons. For the number keys you'll want to change each of their names to num1, num2, num3, and num4. As for their positive button parameters, change their names to 1, 2, 3, and 4, accordingly.

The device detector bool isControllerConnected = false; public string Controller = ""; void DetectController() { try { if(Input.GetJoystickNames()[0] != null) isControllerConnected = true; IdentifyController(); } } catch { isControllerConnected = false; } } This function uses the GetJoystickNames function of the input, which gets and returns an array of strings, which consists of the names of the connected gamepads.

void IdentifyController() { Controller = Input void IdentifyController() { Controller = Input.GetJoystickNames()[0]; }

Adding variables for each control public string PC_Move, PC_Rotate, …; public string Xbox_Move, Xbox_Rotate, …; void SetDefaultValues() { PC_Move = "WASD"; PC_Rotate = "Mouse"; … if(isControllerConnected) { Xbox_Move = "Left Thumbstick"; Xbox_Rotate = "Right Thumbstick"; … }

Control display function void OnGUI() { GUI.BeginGroup(new Rect( Screen.width /2 - 300, Screen.height / 2 - 300, 600, 400)); GUI.Box(new Rect(0,0,600,400), "Controls"); GUI.Label(new Rect(205, 40, 20, 20), "PC"); GUI.Label(new Rect(340, 40, 125, 20), "Xbox 360 Controller"); GUI.Label(new Rect(25, 75, 125, 20), "Movement: "); GUI.Button(new Rect(150, 75, 135, 20), PC_Move); GUI.Button(new Rect(325, 75, 135, 20), Xbox_Move); … GUI.EndGroup(); }

Creating control profiles public enum ControlProfile { PC, Controller }; public ControlProfile cProfile; Add these lines of code before the line of code where you call the IdentifyController() function in the if statement: cProfile = ControlProfile.Controller; else cProfile = ControlProfile.PC; void SwitchProfile (ControlProfile Switcher) { cProfile = Switcher; }

Switching Control Profiles This block of code would be placed in the OnGUI function GUI.Label(new Rect(450, 345, 125, 20), "Current Controls"); if(GUI.Button(new Rect(425, 370, 135, 20), cProfile.ToString())) { if(cProfile == ControlProfile.Controller) SwitchProfile(ControlProfile.PC); else SwitchProfile(ControlProfile.Controller); }

GUI interaction function add to onGUI(), just before the line where the group ends: GUI.Label(new Rect(450, 345, 125, 20), "Current Controls"); if(GUI.Button(new Rect(425, 370, 135, 20), cProfile.ToString())) { if(cProfile == ControlProfile.Controller) SwitchProfile(ControlProfile.PC); else SwitchProfile(ControlProfile.Controller); }

Swapping control schemes Unity doesn't allow us to edit the input properties while in-game, we will add a function to our script that will allow the player to switch between control schemes.