Time for action – create a new MouseFollow Script
- In the Project panel, right-click/alternate-click on an empty chunk of space and navigate to Create | JavaScript. Alternatively, you can navigate to Assets | Create | JavaScript in the menu at the top of the screen, or use the Create button at the top of the Project panel.
- A new Script is added to the Project panel. Name it
MouseFollow
. - Drag-and-drop your new
MouseFollow
Script onto your Paddle GameObject. - Double-click to open the Script in MonoDevelop. Just as before, we're going to add a single, simple line of code inside the curly braces (sandwich buns) of the
Update
function (sandwich):function Update () { transform.position.x = 2; }
- Add a Rigidbody component to Paddle by navigating to Component ...
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.