x


sniper mouse sensitivity problem

i have a sniper and it zooms in, except im using the fps controller thing that came with unity and its in C#, and i dont know any C#. when i zoom in heaps moving the mouse 1 pixel across the screen will move the camera heaps so i cant aim at anything right. i want the sensitivity to go down to 1.5 when the right mouse button is down and go back to 15 when it is up, doesn anyone know how to do that?

more ▼

asked Nov 09 '11 at 05:27 AM

sam32x gravatar image

sam32x
178 42 57 63

this is the script if you dont have it for some reason

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 MouseLook : 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;

    void Update ()      
    {
       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 ()
    {
       // Make the rigid body not change rotation
       if (rigidbody)
         rigidbody.freezeRotation = true;
    }
}
Nov 09 '11 at 05:28 AM sam32x

Protip- learn some C#.

Nov 09 '11 at 05:32 AM syclamoth

That is what I did as well. I really prefer JavaScript over C#, but I slowly learned C# and it has helped me a ton!

Nov 09 '11 at 09:19 AM LegionIsTaken
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

You see those two values sensitivityX and sensitivityY? Make them go waaay down when you zoom in. Then put them back up again when you zoom out again!

From another C# script:

MouseLook fpLook = Camera.main.GetComponent<MouseLook>();
fpLook.sensitivityX = 0.5f;
fpLook.sensitivityY = 0.5f;
more ▼

answered Nov 09 '11 at 05:32 AM

syclamoth gravatar image

syclamoth
15k 7 15 80

yes i know to do that but i dont know C# so i dont know how

Nov 09 '11 at 05:53 AM sam32x

Fine fine I'll spell it out for you.

Nov 09 '11 at 05:55 AM syclamoth
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x183
x57
x23
x21
x2

asked: Nov 09 '11 at 05:27 AM

Seen: 939 times

Last Updated: Nov 09 '11 at 09:19 AM