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.
Abstracting axis input - Unity Tutorial
From the course: Advanced Unity 2D: Platformer Player Movement
Abstracting axis input
- So now that we're keeping track of an axis state, we need a way to actually convert this to a button press and get a value out to determine whether the button is being pressed or not. In order to do this, we're gonna need to test the value that we're getting back from the axis itself, inside of our axis state. Let's go back into our scripts and open the InputManager. We're gonna create a new enum, we'll make this public enum called Condition. And just like we would do normal conditionals in coding, we're gonna keep track of the value of greater than or less than as it relates to the off value of the InputAxisState. Let's add these two properties to our enum. Now, inside of the InputAxisState class, let's add a new property to keep track of what Condition we should be testing for. Now that we have the Condition, we actually need a way of calculating the value. One way that we can do this is by creating a getter for the value property. Getters and setters allow us to do additional…
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
-
-
-
-
-
-
-
-
-
-
-
-