Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by NoirKurosuKai · Jul 31, 2016 at 12:18 PM · c#mouselookhorizontal-slider

Adjusting Mouse Sensitivity through GUI.HorizontalSlider (c#)

I have here a character controller script where bothe the movement and camera rotation are in one script. 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:

 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:

 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);
     }
  
 }    
 
 
Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image NoirKurosuKai · Aug 01, 2016 at 02:04 PM 0
Share

Still need help pls

avatar image Glurth · Aug 01, 2016 at 02:41 PM 0
Share

I don't understand what "camera -sensitivity" means.

avatar image NoirKurosuKai Glurth · Aug 02, 2016 at 12:50 AM 0
Share

its mouse sensitivity

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by TerkMaker · Jul 18, 2017 at 01:29 PM

Hi, I solved the script, the only thing you have to do is to put the content of a OnGui inside a void, important not to do the OnGui void because it will fail, Here is the script solved:

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
  public void Update () {
      Rect slider = new Rect (50, 30, 100, 30);
      hSliderValue = GUI.HorizontalSlider(slider,hSliderValue,1.0f,100.0f);
  }

}

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer

Limiting the camera's rotation using quaternions, camera sticking to top/bottom limit angles 0 Answers

How to freeze a character controller camera 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges