Using all three dees
Now that we know how to track the mouse left and right with the paddle, it's not a huge leap of logic to make our paddle track the y
position of the mouse, and translate it into z
coordinates. Remember that we're working with two different planes here:
The flat, two-dimensional plane of the computer screen
Horizontal X-axis
Vertical Y-axis
Origin point (0, 0) at the bottom-left of the screen
The deep, three-dimensional intersecting planes of our game world
Horizontal X-axis
Vertical Y-axis
Deep Z-axis
Origin point (0, 0, 0) in the middle of the world where the three planes meet
We're going to track the y
movement of the mouse, and map it onto the z
movement of the paddle to make it move toward and away from the player. If instead we map the y
position of the mouse to the y
position of the Paddle, the Paddle will move up and down from the ground to the sky, which is not quite what we're after.