Trying to destroy a bullet but it freezes! (JS)

Hey there,
I’ve been trying to create a projectile which gets destroyed after a set amount of time. The problem I’m having is that the bullet freezes when it should be destroyed. I’m using prefabs to create the instances.

Here is the code I used, I apologise if not all of it is relevant:


var bullet : Rigidbody;
var speed : float = 500.0f;

function Update () {
	if (Input.GetMouseButtonDown(0))	
		var latestBullet = Instantiate(bullet, this.transform.position, transform.rotation);
		latestBullet.AddRelativeForce(Vector3.forward * speed);
		Destroy (latestBullet, 0.2f);

Below is an image depicting what happens, though I understand that a still image doesn’t really capture everything.

you need to Destroy(latestBullet.gameObject,0.2f);

because your code is just deleting the rigidbody from the prefab, while leaving everything else like the mesh renderer in place :slight_smile: