O'Reilly logo

Learn Unity For 2D Game Development by Alan Thorn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter     9

Input for 2D Games

In this chapter we’ll talk about user input for 2D games, specifically input from the keyboard, mouse, and mobile devices. Input is critical for any game, whether 2D or not. Without input, a game cannot be interactive. For most 2D games, we need to read input that maps directly to 2D space, in terms of pixel positions. However, because Unity is a 3D engine and our objects exist in three-dimensional space, we’ll also need to convert screen space positions to world space positions. For this chapter, I’ll be working from a premade, basic 2D project, which is included in the book companion files (in Project_Files/Chapter09/); however, you can work along with your own projects instead, if you want to. Some points ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required