H, i have a problem

Hi, i have a script for a projectile that’s going upwards but after i shoot one time i can’t shoot again.
This is the script:

using UnityEngine;

public class BulletMovement : MonoBehaviour
{

    public GameObject bullet;
    public float speed;
    private bool isActive=false;
    public float maxY;
    public Transform spawnPos;
    public GameObject spawnee;


    private SpawnerWeapon spawnerWeapon;

    // Use this for initialization
    void Start()
    {
        if (isActive == false)
        {



            if (Input.GetMouseButtonDown(0))
            {
                isActive = true;
                

            }
        }

    }

    // Update is called once per frame
    void Update()
    {


        if (isActive == false)
        {



            if (Input.anyKeyDown)
            {
                isActive = true;


            }
        }
        if (bullet.transform.position.y < maxY && isActive == true)
        {
            bullet.transform.Translate(new Vector3(0, speed, 0) * Time.deltaTime);
        }
        if (bullet.transform.position.y >= maxY)
        {
            
            Debug.Log("Distrus");
            Destroy(gameObject);

            isActive = false;
            Instantiate(spawnee, spawnPos.position, spawnPos.rotation);
            return;



        }

    }

    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "Enemy")
        {

            Debug.Log("Lovit");
            Destroy(gameObject);
            ;
            
            isActive = false;
            Instantiate(spawnee, spawnPos.position, spawnPos.rotation);
            return;

        }
    }
}

Hi ,

I Don’t know why you Use is active and its not necessary to to check Input.GetMouseButtonDown at Start(because it calls just one time at running the code and if you don’t left click at start it will be useless.)

using UnityEngine;

public class BulletGeneration : MonoBehaviour
{

    public GameObject bullet;
    public float speed;
    public float maxY;
    public Transform spawnPos;
    public GameObject spawnee;

    private SpawnerWeapon spawnerWeapon;

    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            bullet = Instantiate(spawnee, spawnPos.position, spawnPos.rotation);//must assign the instance GO to bullet
            if (bullet.transform.position.y < maxY)
            {
                bullet.transform.Translate(new Vector3(0, speed, 0) * Time.deltaTime);//you can use Vector3.up*speed instead of (new Vector3(0,speed,0)) , it's much more performant.
            }
        }
        if (bullet != null && bullet.transform.position.y >= maxY)
        {
            Destroy(bullet);
        }

    }

    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "Enemy")
        {
            Destroy(bullet);
            bullet = Instantiate(spawnee, spawnPos.position, spawnPos.rotation);//must assign the instance GO to bullet
        }
    }
}

I’ve changed it a little bit , it’s not Bulletmovement script i think it’s BulletGeneration script and you must add it to your character GameObject(not to all bullets)

movement.it’s better to have a BulletMovement Script on all bullets for adding bullet movement code in that

for adding this line:transform.Translate(new Vector3(0, speed, 0) * Time.deltaTime);