From the course: Advanced Unity 2D: Platformer Player Movement
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Building an input state class - Unity Tutorial
From the course: Advanced Unity 2D: Platformer Player Movement
Building an input state class
- So now that our InputManager is able to take inputs from Unity and convert them into buttons that our game can use, we're going to need a place to store whether the button has been pressed or released. To get started, let's go back into our Projects folder and in scripts we're going to create a new C# script called inputState. Open it up in MonoDevelop and we'll begin adding the code. Now just like we did with our InputManager, we're going to need a special class in order to keep track of the actual button state itself. Above our inputState, let's create this new class. We'll make is a public class called buttonState. Now since we're not going to be changing this in the IDE, we don't need to worry about serializing the object. All we need to do is have a boolean that keeps track or whether the button is pressed or not. We'll make this a public boolean called value. Next, in our inputState we're going to need to keep a collection of all the button states in our game. In order to do…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Input introduction5m 52s
-
(Locked)
Building an input manager5m 55s
-
(Locked)
Abstracting axis input5m 2s
-
(Locked)
Building an input state class4m 31s
-
(Locked)
Tracking button release states4m 7s
-
(Locked)
Reading from the input state class4m 39s
-
(Locked)
Building multiple input managers for multi-player games2m 52s
-
-
-
-
-
-
-
-
-
-
-
-