Hey guys! Cody here. It seems I am having a few issues. I created a scope on a sniper to get the basics down and I am using the FOV cam. I was wondering if there was a way to modify the zoom so while im zoomed in the sensitivity goes down to about 2 or 3. Heres my script. Feel free to modify or make any changes. Thanks to anyone who helps!
using UnityEngine;
using System.Collections;
/// MouseLook rotates the transform based on the mouse delta.
/// Minimum and Maximum values can be used to constrain the possible rotation
/// To make an FPS style character:
/// - Create a capsule.
/// - Add the MouseLook script to the capsule.
/// -> Set the mouse look to use LookX. (You want to only turn character but not tilt it)
/// - Add FPSInputController script to the capsule
/// -> A CharacterMotor and a CharacterController component will be automatically added.
/// - Create a camera. Make the camera a child of the capsule. Reset it's transform.
/// - Add a MouseLook script to the camera.
/// -> Set the mouse look to use LookY. (You want the camera to tilt up and down like a head. The character already turns.)
[AddComponentMenu("Camera-Control/Mouse Look")]
public class mouseLookAndHide : MonoBehaviour {
public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
public RotationAxes axes = RotationAxes.MouseXAndY;
public float sensitivityX = 15F;
public float sensitivityY = 15F;
public float minimumX = -360F;
public float maximumX = 360F;
public float minimumY = -60F;
public float maximumY = 60F;
float rotationY = 0F;
public bool showingMouse;
void Update ()
{
//if you press "r" and the mouse is not shown then the mouse is shown and movable then execute code
if(Input.GetKeyDown(KeyCode.M) && showingMouse == false){
showingMouse = true;
Screen.showCursor =true;
Screen.lockCursor = false;
}
//if you press "r" and the mouse is shown then make it not shown
else if(Input.GetKeyDown(KeyCode.M) && showingMouse == true){
showingMouse = false;
Screen.showCursor =false;
Screen.lockCursor = true;
}
if (axes == RotationAxes.MouseXAndY)
{
float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX;
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
}
else if (axes == RotationAxes.MouseX)
{
transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0);
}
else
{
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y, 0);
}
}
void Start ()
{
showingMouse = false;
Screen.showCursor = false;
Screen.lockCursor = true;
// Locks in center of screen, Hides cursor
//Screen.lockCursor = true;
//Screen.showCursor = false;
// Make the rigid body not change rotation
if (rigidbody)
rigidbody.freezeRotation = true;
}
}
Also I know the code is the original I just implemented some of my own things. Thanks!