I am trying to create the shooting mechanic for a 2D topdown shooter. I need to shoot bullets at the location of the mouse. I have the code working which instantiates the bullets and shoots them in different directions based on the mouse, but the problem is that Input.mousePosition uses pixel coordinates that are not based on the position of the camera or player. By this, I mean that the bullets only shoot as they should when my character stands on (0, 0) of the pixel coordinates.
var mousePos: Vector2 = Input.mousePosition;
var bulletClone : Rigidbody2D = Instantiate(bullet, transform.position, transform.rotation);
bulletClone.rigidbody2D.AddForce(mousePos);
Also, I do not know how to rotate the bullets to the face the mouse. If I was able to do that, it would be very easy to move the bullets towards the mouse. If anyone can help me with this predicament, I would be very very appreciative.
Thank you kindly!