Input for 2D Games
Alan Thorn · Apress eBooks · 2013
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 covered in this chapter include: