Limit rotation of weapons with mouse help

I have a robot who shoots paintballs out of two paintball guns mounted as arms. These rotate to follow the mouse and shoot in that direction when fired. At the moment the guns face backwards sometimes when the mouse goes behind the player. I need them to constantly face forward- do I need to limit rotation? Here is my code so far…

using UnityEngine;
using System.Collections;
public class MyScript : MonoBehaviour {
    private Vector3 inputRotation;
    private Vector3 mousePlacement;
    private Vector3 screenCentre;
    void Update () {
    transform.rotation = Quaternion.LookRotation(inputRotation);

    void FindStuff () {
    screenCentre = new Vector3(Screen.width * 0.5f,0,Screen.height * 0.5f);
    mousePlacement = Input.mousePosition;
    mousePlacement.z = mousePlacement.y;
    mousePlacement.y = 0;
    inputRotation = mousePlacement - screenCentre;

Any help or pointers would be great!


Quick, untested idea. Limit your mousePlacement.z to positive values >= 1. Just something like:

if (mousePlacement.z < 1) mousePlacement.z = 1;

This should accomplish two goals. First the point you look at will always be in front of the robot, so his guns will never face backward. Second you will never produce an inputRotation of (0,0,0). According to the docs, LookRotation() called with (0,0,0) will log an error.