How I make the clone to destroy after a collision?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GunAK : MonoBehaviour
{
public float moveForce;

public GameObject bullet;
public Transform gun;

public float shootRate;
public float shootForce;
private float m_shootRateTimeStamp;

Animator m_Animator;

public ParticleSystem flash;
public ParticleSystem bulletLine;

void Update()
{
    if (Input.GetMouseButtonDown(0))
    {
        if (Time.time > m_shootRateTimeStamp)
        {
            GameObject go = (GameObject)Instantiate(bullet, gun.position, gun.rotation);
            Destroy(go, 6f);
           

            go.GetComponent<Rigidbody>().AddForce(gun.forward * shootForce);
            m_shootRateTimeStamp = Time.time + shootRate;

        }

        flash.Play();
        bulletLine.Play();
    }


}

},

I think you mean bullet in reference to clone? That would be needed in the script of the bullet itself. A simple void OnCollisionEnter(Collider other) and within that have Destroy(gameObject);, this is assuming you don’t want to worry about what it hits, rather than if it just hits anything.

But if you plan on using real-world bullets, instead of images, you really should look into Object Pooling, as this will allow you to not receive the lag you would get from normal Instantiation and Destroying.

Judging by the fact you wish to have a 6 sec timer to destroy the bullet, in case it doesn’t hit anything, that would also need to be within the bullets script. Add a simple timer of 6 secs, then destroy(or disable if object pooling) :slight_smile: