Why didn't the Paddle animate before?
When we wrote the line transform.x = 2
, the Paddle just jumped into position; it didn't go anywhere, like it does now. Why is that?
The Update
function is still getting called multiple times. But each time, it's putting the Paddle at two units on the X-axis. The value of x
changes on every Update
, but it changes to the same thing. So, once Paddle is in position, it doesn't appear to move.
With our new modified line of code, the x
position of the Paddle is changing by 0.2
every time the Update
function is called, so Paddle moves across the screen.
An important part of being a beginner programmer is keeping a positive attitude. You should start with the assumption that what you want to do can be done—anything is possible. We now know how to set the position of the paddle. With your positive, can-do attitude, you might imagine that to get the paddle moving around with the mouse, you could find the position of the mouse, and set the transform.position.x
property...