From the course: Advanced Unity 2D: Platformer Player Movement
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Changing the direction the player is facing - Unity Tutorial
From the course: Advanced Unity 2D: Platformer Player Movement
Changing the direction the player is facing
- [Voiceover] Now, we're ready to create our first behavior. In this one, we're going to make a simple behavior, that simply tells the direction that our player is facing. In order to do this, we're going to need to create a new script, called face direction. Inside of our script folder, select C sharp script, and make this face direction. We'll open this up in MonoDevelop. And now that this is open in MonoDevelop, let's change the class that face direction extends. In this case, we're going to replace mono behavior with abstract behavior. Next, we're going to want to go into the update loop, and start getting the values of whether the left and right key are set. You remember that we set an array for buttons that we can map to this behavior in our abstract behavior, and all of that's going to be inherited into the face direction. So, just like we did with simple movement, let's create two gullions that will keep track of whether the right and left keys are being pressed. You'll see…
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
-
-
-
-
-
-
-
-
-
-
-