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:
Slider Script:
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);
}
}