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

Changing the direction the player is facing - Unity Tutorial

From the course: Advanced Unity 2D: Platformer Player Movement

Start my 1-month free trial

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…

Contents