Game Development Reference
In-Depth Information
var rotation : Quaternion = Quaternion.FromToRotation(Vector3.
up, contactPoint.normal);
GameObject.Instantiate(explosionParticle, contactPoint.point,
rotation);
KillObject();
}
public function KillObject () : void {
//Stop the emit the particle
var emitter : ParticleEmitter = GetComponentInChildren(ParticleE
mitter);
if (emitter != null) {
emitter.emit = false; // Stop Emit
}
//In here We set the particle to auto destruct to destroy itself
after a life time (or we can setup it in the editor)
var particleAnimator : ParticleAnimator = GetComponentInChildren
(ParticleAnimator);
if (particleAnimator != null) {
particleAnimator.autodestruct = true;
}
//Detach the trail renderer in our particles
transform.DetachChildren();
//Destroy this Object
GameObject.Destroy(gameObject);
}
10. Next, add the Rocket script that we created by dragging the script to the rocket
object in the Hierarchy .
11. Then, go to the object's Inspector view to add the Box Collider to the rocket object
by going to Component | Physics | Box Collider .
When we add the Box Collider to the new object, the Box Collider will
automaically adjust its size to it around the object. This is why we
don't have to set up the size or the posiion of the Box Collider .
12. Then, we go to the Inspector view and set the following:
Transform
Position : X: 0 , Y: 0 , Z: 0
 
Search WWH ::




Custom Search