Game Development Reference
In-Depth Information
Rigidbody
Use Gravity : Uncheck (We don't need the gravity for our rocket)
Rocket (Script)
Explosion Particle : explosion (Drag the explosion built-in prefab in the
Standard Assets | Particles | Legacy Particles | explosion )
13. Next, we will add the built-in Smoke Trail prefab as a child of this rocket object.
Go to the Project view, and click on Standard Assets | Particles | Smoke and drag
the Smoke Trail prefab to the rocket object in the Hierarchy view.
14. Then, we will click on the Smoke Trail object in the Hierarchy view and set the
following in its Inspector view:
Transform : X:0 , Y: 0 , Z: -0.25
Ellispsoid Particle Emitter :
Min Size : 0.25
Max Size : 0.65
Min Energy : 0.75
Max Energy : 1
Particle Animator
Size Grow : 0.5
15. Next, we will create a new prefab for our rocket object. Go to Assets | Create |
Prefab and name it Rocket , and then drag our rocket object in the Hierarchy view
to Rocket prefab, which we just created in the Project view. Finally, we remove the
rocket object from the Hierarchy view by deleing it, and now we have the new
Rocket prefab.
16. Go back to the RocketLauncher script by going to the Project view, double-click
on the RocketLauncher script to go to MonoDevelop , and add the following new
script at the beginning:
public var smoke : GameObject;
public var smokePosition : Transform;
public var rocket : ConstantForce;
public var speed : float = 10;
public var ammoCount : int = 20;
private var lastShot : float = 0.0;
17. Go to the Fire() funcion and add the following highlighted code:
public function Fire(_reloadTime : float) : void {
if (Time.time > (_reloadTime + lastShot) && ammoCount > 0) {
 
Search WWH ::




Custom Search