© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2024
C. HardmanGame Programming with Unity and C#https://doi.org/10.1007/978-1-4842-9720-9_20

20. Dashing

Casey Hardman1  
(1)
West Palm Beach, FL, USA
 

To give the player a bit more interesting movement, we’re going to implement an option for them to quickly “dash” in the direction they’re moving – or, more specifically, in the direction they have held down with the movement keys. If they’re holding W and D, they’ll dash diagonally forward and right, for example.

When dashing, the player will stop moving by normal means, giving control to the dash movement instead. Once they finish dashing, we’ll revert control back to the normal movement, and we’ll set the movement ...

Get Game Programming with Unity and C#: A Complete Beginner’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.