need help

im trying to make my bullets disappear when they reach the cursor but im getting an error,
i wrote this:

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

public class pewpew : MonoBehaviour
{
    private Vector2 target;
    public float speed;
    // Start is called before the first frame update
    void Start()
    {
        target = Camera.main.ScreenToWorldPoint(Input.mousePosition);
    }

    // Update is called once per frame
    void Update()
    {
        transform.position = Vector2.MoveTowards(transform.position, target, speed * Time.deltaTime);
        if(transform.position == target){

        }
    }
}

What error you get?
Use Debug.Log, to track issues.

1 Like