Unity Ninja Unity 3D Forum
To have exclusive access to all downloads, recourses and links within this forum, a free registered account is required. Just a heads up Wink

You are not connected. Please login or register

Unity Ninja Unity 3D Forum » HELP » Help (General) » Adjusting Camera Sensitivity through GUI.HorizontalSlider (c#)

Adjusting Camera Sensitivity through GUI.HorizontalSlider (c#)

View previous topic View next topic Go down  Message [Page 1 of 1]

Natsuki Subaru


Member [Lv. 1]
Member [Lv. 1]
I want to make a simple mouse sensitivity slider but i dunno how to start. Can anyone help me fix this please? Do i have to access the "publicfloat mousesensitivity = 5.0f;"? if so can anyone help me Thanks again! Also if possible can you guys provide the editted code as a whole kinda sorta still a noob sorry...

Controller script:

Code:

using UnityEngine;
 using System.Collections;
 
 public class Controller : MonoBehaviour {
 
     public float movementspeed = 5.0f;
     public float mousesensitivity = 5.0f;
     public float jumpspeed = 20.0f;
 
     float  verticalRotation = 0;
     public float updownrange = 60.0f;
 
     float VerticalVelocity = 0;
 
     // Use this for initialization
     void Start () {
         Screen.lockCursor = false;
     }
    
     // Update is called once per frame
        
         void Update () {
             CharacterController cc = GetComponent <CharacterController> ();
 
     //Rotation
         float rotleftright = Input.GetAxis("Mouse X") * mousesensitivity;
             transform.Rotate (0, rotleftright, 0);
 
         verticalRotation -= Input.GetAxisRaw("Mouse Y") * mousesensitivity;
             verticalRotation = Mathf.Clamp (verticalRotation,-updownrange ,updownrange);
                 Camera.main.transform.localRotation = Quaternion.Euler (verticalRotation, 0, 0);
 
 
     //Movement
 
 
         float forwardspeed = Input.GetAxis("Vertical") * movementspeed ;
         float sidespeed = Input.GetAxis("Horizontal") * movementspeed ;
 
         VerticalVelocity += Physics.gravity.y * Time.deltaTime;
 
 
         Vector3 speed = new Vector3 (sidespeed, VerticalVelocity , forwardspeed );
 
         speed = transform.rotation * speed;
 
    
 
         cc.Move ( speed * Time.deltaTime );
     }
 }

Slider Script:

Code:

using UnityEngine;
   using System.Collections;

    public class HSlider : MonoBehaviour {
    float hSliderValue = 5.0f;
    // Use this for initialization
    void Start () {
 
    }
 
    // Update is called once per frame
    void Update () {
 
    }
    OnGUI {
        Rect slider = new Rect (50, 30, 100, 30);
        hSliderValue = GUI.HorizontalSlider(slider,hSliderValue,1.0f,100.0f);
    }
 
}    

View user profile

jakeyiii


Member [Lv. 3]
Member [Lv. 3]
Hello

We see that you have some issues with your project/script, however we can help you for a price. If you would like us to work for you then please feel free to contact us at http://RenntekStudios.co.uk or on Skype at RenntekStudios thanks

Our prices are very cheap. Little errors we can fix for free, otherwise projects we can discuss prices. Hope you get in touch shortly thank you...

View user profile

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum