Time for action – listen to the paddle

  1. Add this line of code beneath the existing line of code:
        Debug.Log(Input.mousePosition.x);
    
  2. Your entire Script should look like this:
        function Update () {
              transform.position.x = Input.mousePosition.x;
              Debug.Log(Input.mousePosition.x);
        }
  3. Save and test your game.

Look at the very bottom of the screen for the results of your Debug.Log() statement. If nothing shows up, follow these steps to enable Console statements:

  1. Navigate to Window | Console in the menu.
  2. This is an important window! Dock it to your layout by clicking and dragging it beneath your Game view.
  3. Ensure that Console messages are enabled by clicking on the little button with the comic book speech bubble.

As you move the mouse cursor left and right, ...

Get Unity 4.x Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.