Bullet clones will not be destroyed.

So i’ve been working on this mechanic for some time and finally got it to work, I just need the clones to destroy themselves after a few seconds (some bullets will run of into space). Here is my code, thanks!

using UnityEngine;
using System.Collections;

public class Turret3 : MonoBehaviour {
	
	public GameObject bullet;
	public GameObject cannonFlash;
	
	private GameObject spawnPt;

	// Use this for initialization
	void Start () {
		
		spawnPt = GameObject.Find ("oneSpawn");
		
		cannonFlash.SetActive(false);
	
	}
	
	// Update is called once per frame
	void Update () {
	
		 Vector3 fwd = transform.TransformDirection(Vector3.forward);
		
	if (Input.GetButtonDown ("Fire1")) 
		
		{
		
		Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
			
		RaycastHit Hit;
			
		 if (Physics.Raycast(ray, out Hit, 1000))
				
		{
					
	        Debug.DrawLine(ray.origin, Hit.point);
			
			GameObject newProjectile = Instantiate (bullet, spawnPt.transform.position, transform.rotation)as GameObject;
					
			newProjectile.transform.LookAt (Hit.point);
					
			newProjectile.rigidbody.AddRelativeForce(Vector3.up + Vector3.forward * 5000);
					
		    Destroy (newProjectile, 5);
				
				print("" + Hit.point);
		}
			
					cannonFlash.SetActive(true);

			
		}
		
		if(Input.GetButtonUp ("Fire1"))
			
		{
			cannonFlash.SetActive(false);

		}
	}
}

Try putting a simple script on the bullet Prefab that only allows it to exist for a set time…

In other words, a script with a timer, that when it runs out, Destroy()s the parent GameObject.

If you need me to, I will write the script.

var lifeTime = 5.0;

    function Awake ()
    {
    Destroy(gameObject, lifeTime);
    }

Attach to the bullet, should only stay in the scene for 5 seconds here. Change the value as required :wink: