O'Reilly logo

Unity 3D Game Development by Example by Ryan Henson Creighton

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

Time for action - animate the Paddle

  1. Jump back into your MouseFollow Script if you're not there already by double-clicking on it in the Project panel.
  2. Change the line of code in the Update function ever so slightly so that it reads as follows:
    function Update () {
    transform.position.x += 0.2;
    }
    

The changes are very subtle. We added a plus sign (+) before the equals sign (=), and we made the number smaller by adding a zero and a decimal place in front of it, changing it from 2 to 0.2.

Save the Script and test your game. The Paddle should scoot out the way, and fly straight off the right-edge of the screen!

What just happened - what witchcraft is this?

We made the 2 smaller, because the Paddle would have just rocketed off the screen in a twinkling ...

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