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.
Making the player run - Unity Tutorial
From the course: Advanced Unity 2D: Platformer Player Movement
Making the player run
- Now you may have noticed that our player is a little bit slow when he walks. Of course, we can update the speed but a better solution is to actually add a new key that'll modify the speed at which he walks and allow him to run. In order to do this, we're gonna need to open up our walk script. In here, we're gonna add a new public property that'll represent the multiplier that will use to increase the speed value when the run key is being pressed. Create a public float and call this runMultiplier. And we'll set this value to 2. This means when we're running, we'll be actually multiplying the speed by 2 and make him look like he's going faster. Next, we're gonna need to keep track if the run key is being pressed. Let's copy the left key and change this to run and set the inputState to 2, we'll add a new button later. Then, before we actually calculate the velocity X let's modify the temp speed. In this case, we're gonna want to make sure that run is actually being pressed and that the…
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
-
-
-
-
-
-
-
-
-
-
-