Throwing a ball, can't go over 180°

Hello;

I have a problem which is, I think stupid. There is my story.

I’m making a FPS, and I have a weapon which throw balls where the player is aiming. It’s workig when I shoot from 0° to 180°, but from 180° to 360° it’s like the direction of the shoot is stuck.

There is the step I followed :

1 - I Instantiate my ball at the position of the player.
2 - I calculate the target which is the center of the screen, converted on a position in the world.
3 - I calculate the vector direction between the player and the target.
4 - I add a force on the newly instantiated ball with the direction calculated multiplied by a coef of power.

There is the code :

// Instantiation of the new bullet
newBullet = (GameObject) Instantiate(ammoType, this.transform.position, this.transform.rotation);
// I calculate the direction byt substracting the position of the player with the center of the screen converted in a world position.
Vector3 direction = Camera.mainCamera.ScreenToWorldPoint(new Vector3(Screen.width/2, Screen.height/2, 10)) - this.transform.position;
direction.Normalize();
// I'm adding a force to the bullet
newBullet.GetComponent<Rigidbody>().AddForce(direction * 1000);

I’m pretty sure I made a stupid mistake, but, which one!

Thanks a lot.

Is “this” or the object the script is attached to, the camera? If not, it should be.
If you want the bullet to come out of a gun or something, make sure it is parented to the camera and that the screen point is way in front of the gun.

Good luck!

Thanks for your answer.

My script is attached to the camera and it’s firing correctly, the only problem is that it stop working when I aim from 180° to 360°. I didn’t find yet the answers.