I am still pretty new coding and I added this destruction script to the Bullet but I made it once fired after a certain amount of seconds, the prefab would destroy itself, Im only wanting to destroy the clone any ideas?
My Script:
public class BulletDestroy : MonoBehaviour {
void Update ()
{
if (Input.GetButtonDown ("Fire1"))
{
Destroy (gameObject, 1.5f);
}
}
}
// Pistol.cs, attach to your weapon GO
public class Pistol : MonoBehaviour {
public GameObject bulletPrefab; // drag here a reference to the bullet GO you want to instantiate
void Update () {
if (Input.GetButton ("Fire1"))
Instantiate (bulletPrefab); // you can adjust position and rotation here
}
}
// BulletDestroy.cs, attach to your bullet GO
public class BulletDestroy : MonoBehaviour {
void Start () {
Destroy (gameObject ,1.5f);
}
}