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.
Reading from the input state class - Unity Tutorial
From the course: Advanced Unity 2D: Platformer Player Movement
Reading from the input state class
- So now that we have our input manager talking to the input state, the only thing left is for us to map this over to the simple movement script we created earlier. But before we do this, we actually need to get the value out of the input state for the keys that are being pressed. Let's open up our input state class. Inside of this, we'll create a new public method called get button value, that returns a bullion. Here you see we're passing in our key enum, and we'll need to make sure that the value actually exists on the button states before we try to get it. Next, we'll return that value. If there is no value, we'll simply return faults. Next, let's take a look at our simple movement script. Here we're going to need to add two new properties. One that manages the actual input keys that we're mapping to, and the other the input state itself. Let's create a public property. This will be an array of buttons, and we'll call this input. Next, we'll make a private property for the input…
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
-
-
-
-
-
-
-
-
-
-
-
-