How can i Instantiate my projectile?

Hello folks!
So I have this problem where I am blocked with a code, the code in question allows my character to shoot a fireball at the place where I click with my mouse, but, instead of doing that, the fireball goes to the place where the camera is, (the camera is not moving, only the character),
I thinks it is a problem with Instantiate and the mousePos, any of you know how I can resolve this issue?

here is the code:

void Update()
            if (Input.GetMouseButtonDown(0))
                GameObject sort = Instantiate(projectile, transform.position, 
                Vector2 mousePos = 
                Vector2 myPos = transform.position;
                Vector2 direction = (mousePos - myPos).normalized;
                sort.GetComponent<Rigidbody2D>().velocity = direction *   

To maje this code I’ve watch this tutoriel on how to make a rougue like:

Hope someone will be able to help me ^^

Thats not Unity, thats math.

I dont know where you instantiate the object or where is the destination. but The direction of the projectile vector must be (Destination position - Origin position) All in world coordinats (not local)

If its not doing what you expect, check where your suposed “origin and destination” really are in the scene.