I am currently using the user’s mouse position to fire bullets in my 2D top down game, but it is not working as intended. Here is my script to determine the user’s mouse position and apply the vector to the bullet:
void Start () {
cam = Camera.main;
Vector3 mouse = cam.ScreenToWorldPoint(Input.mousePosition);
mouse.z = 0;
Vector2 moveVelocity = mouse.normalized * bulletSpeed;
rb.AddForce(moveVelocity);
}
The script works exactly as intended when the player is near the origin of the world, but as the player approaches each side of the world, it starts to malfunction. Here’s a gif showing that interaction: Mouse Issue - Album on Imgur
Basically as I move to the right I can’t shoot to the left, up I cant shoot down, etc. I would appreciate any help, thanks in advance!