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 - make the Hands and Tray follow the Mouse

Any script that we create in Unity is reusable, and we can attach scripts to multiple Game Objects. Let's attach our MouseFollow script to the HandsAndTray Game Object.

  1. Find the MouseFollow script in the Project panel, and drag it onto the HandsAndTray Game Object in the Hierarchy panel. (Make sure to drop it on the parent HandsAndTray Game Object, not the child handsAndTray model.)
  2. Test your game by pressing the Play button.

The hands and tray should follow your mouse the very same way the paddle does. Because we generated a collider on the tray in the FBXImporter settings, the Ball should bounce on the tray just as it does with the Paddle.

What just happened monkey see, monkey do

Because ...

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