I'm using the following script to aim using the mouse at the screen but sometimes the aim device doesn't follow it and stays looking in the same direction. I believe it's due to the mouse position exceeding the screens height and width positions but I can't be sure...Is there anyway to fix this?
I'm using a cube as the firing point for the shots.
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit)) {
AimingTarget = hit.point;
}
transform.LookAt(AimingTarget);