Game Development Reference
In-Depth Information
_guiTexts[i].text = ammo.ToString();
}
}
}
6. Then, we go back to Unity and add the RocketUI script to the RocketUI object
in Hierarchy .
7. In the Hierarchy view, we need to create the RocketLauncher object by go-
ing to GameObject | Create Empty ; name it RocketLauncher and drag it in-
side our gun_model object, as shown in the following screenshot:
8. Now we will create the script to control our RocketLauncher object. Let's go to
Assets | Create | Javascript (for Unity JavaScript users) or Assets | Create | C#
(for C# users), name it RocketLauncher , double-click on it to launch
MonoDevelop , and define the variables as follows:
// Unity JavaScript user:
#pragma strict
var smoke : ParticleSystem;
var rocket : ConstantForce;
var speed :float = 10f;
var ammoCount : int = 20;
private var lastShot : float = 0.0f;
private var _rocketUI : RocketUI;
Search WWH ::




Custom Search