Not Destroying

Hi all,

In the script below my Destroy (theball,5); is not destroying theball - rather it is freezing the ball in mid air. I was wanting to completely remove the ball from the scene.

Any thoughts would be appreciated thanks.

Cheers

Jeff

// Instantiates a projectile every 0.5 seconds,
// if the Fire1 button (default is Ctrl) is pressed.
var myPrefab : Rigidbody;
var throwForce : int = 20;
var fireRate = 0.5;
private var nextFire = 0.0;
function Update () {
if (Input.GetButton (“Fire1”) Time.time > nextFire) {
nextFire = Time.time + fireRate;
var theball : Rigidbody = Instantiate(myPrefab, transform.position, transform.rotation);

theball.velocity = transform.TransformDirection(Vector3 (0,0,throwForce));

Destroy (theball,5);

}
}

Ah ok I see what was going on…I was only removing the rigidbody…not the gameobject.

Now it’s working well however it destroys the gameobject and attached particle instantly (of course) but I’d love it to fade out or at least allow the particle to fade rather than instant destruction.

Is it possible to fade out rather than instantly destroy the gameobject and particle?

Thx

Jeff

If the particle system is on a separate object, you just need to set that object’s parent to null, make it stop emitting, and turn on autoDestruct.

Untested, but alternatively instead of calling Destroy(), you could call a function to fade out the objects materials and the materials assigned to the particle system, and then destroy the object when the alpha value gets below a certain threshold.