Need help firing projectile towards mouse

I am creating a spell based rogue like game (like wizard of legend) and I can’t figure out how to fire a projectile towards the mouse. I am using camera.main.screentoworkdpoint(Input.mouseposition) and it only fires towards the center of the screen. Anyone know how to help or fix this?

This is one of those things that I think the docs could use some clarification on, given the number of times that I’ve seen this kind of issue. The z value of the position you pass into ScreenToWorldPoint denotes the number of units away from the camera you want the point to be. Input.mousePosition, being a Vector2, gets converted to a Vector3 with a z of 0 when being passed in.

The effect of this is that the resulting point you get out is on the near plane of the camera – which if I had to guess is probably 0.3 units away. Make sure that the value you pass in for the z will give you a point at the same depth that you want to use it. If you were to take the default unity scene as an example, you would pass in a value of 10 because the camera is at z = -10, placing the resulting point at z = 0.

My apologies if this text explanation doesn’t click for you, I would create a diagram (which would clear this up instantly) but I am not in the position to do so at the moment.

Ok I will try to figure it out tomorrow and if you are able to make a graph that would help a lot. The game is saved on a different computer so I’ll have access to it tomorrow to try it out. Thanks for you help.