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.
Saving direction state - Unity Tutorial
From the course: Advanced Unity 2D: Platformer Player Movement
Saving direction state
- So now that we know which direction the player is supposed to be facing, it's time for us to hook this up. Now an important thing that we're gonna need to keep in mind is that behaviors are gonna be self-contained. So in the case of the Face Direction behavior it's not necessarily gonna know anything else about Walk or Jump or any of the other behaviors we'll implement later in this course. Now in order for one behavior to communicate to another behavior, we're gonna need a bridge. And the input state class will act as that bridge. Every behavior will point to the input state and read state value. So when it comes to something important like direction we're gonna wanna make sure that we have the direction value accessible through any of the other classes that we have. Now in order to do this, we're gonna take advantage of the fact that the face behavior can talk back to the input state, and the input state will relay that message to other behaviors that are looking at its values…
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
-
-
-
-
Setting up the first character5m 42s
-
(Locked)
Building a test level5m 59s
-
(Locked)
Building the abstract player behavior4m 34s
-
(Locked)
Changing the direction the player is facing2m 52s
-
(Locked)
Saving direction state5m 51s
-
(Locked)
Adding walking to the player2m 50s
-
(Locked)
Making the player run4m 34s
-
-
-
-
-
-
-
-
-
-
-