O'Reilly logo

Unity 4 Game Development HOTSHOT by Jate Wittayabundit

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

Creating the RocksTrigger and Rocks scripts

Now, we are at the last step of this project. We will create the RocksTrigger and Rocks scripts to make the rock fall down.

Engage thrusters

Let's create the RocksTrigger script first by performing the following steps:

  1. Go to the Scripts folder in the Project view to create the script by right-clicking and navigating to Create | C# (for C# users) or Create | Javascript (for JavaScript users) and rename it RocksTrigger.
  2. Double-click on the RocksTrigger script to open it in MonoDevelop and start adding the script as follows:
    // Unity JavaScript user: #pragma strict private var _isTrigger : boolean = false; static var onTrigger : JSDelegate = new JSDelegate(); function OnTriggerEnter(collider : Collider) : ...

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