Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 ChompIV · Jul 09, 2017 at 04:52 AM · tutorialslidermouselookfps controllersensitivity

Anyone have a sensitivity slider script/tutorial used for an fps (using Unity's mouselook controller?)

Ive been trying to figure this out for months, it isnt hard, its just im a beginner and its a giant road block in my game. If anyone has their own FPS game using unity's FPSController and mouselook script please help me it would be very very appreciated. :) Also please tell me how to use it.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by shrey150 · Jul 09, 2017 at 08:27 AM

This post touches on how to do this, Unity made this quite confusing to modify since MouseLook is private: http://answers.unity3d.com/questions/1095401/unity-5-access-first-person-controller-mouse-look.html

Basically, add this function to FirstPersonController.cs to allow us to modify the private variables:

  public void ChangeMouseSensitivity(float X, float Y){
      m_MouseLook.XSensitivity = X;
      m_MouseLook.YSensitivity = Y;
  }

Then on another script, write a function that takes the slider value and sets that using the previous function. This script should be on the player GameObject, where the FPS script is. Something like this:

 using UnityEngine;
 using UnityStandardAssets.Characters.FirstPerson;
 using UnityEngine.UI;
 
 public class ChangeSettings : MonoBehaviour {
 
     public Slider sensitivitySlider;
 
     public void ApplySensitivity()
     {
         GetComponent<FirstPersonController>().ChangeMouseSensitivity(sensitivitySlider.value, sensitivitySlider.value);
     }
 }

Now in the editor, set sensitivitySlider to the one you want to use and add ApplySensitivity() as an OnClick event on the button used to apply the sensitivity. Hope this helped!

EDIT: You can make this even easier. Under the OnValueChanged event on the slider, add ApplySensitivity(). That way you can try the sensitivity in real-time.

Comment
Add comment · Show 9 · 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
avatar image ChompIV · Jul 10, 2017 at 04:34 AM 0
Share

Im stuck, I did the first steps, but Im confused on how I set sensitivitySlider to the slider I want when the slider I want is on a different scene? And in the editor how do I add ApplySensitivity() as an OnClick event on the button used to apply the sensitivity? Other then that it looks good, please help, Thank you so much!

avatar image shrey150 ChompIV · Jul 10, 2017 at 08:14 AM 0
Share

In the editor, click on the Player GameObject from the hierarchy. Under the FirstPersonController component, there should be a new empty slot called "Sensitivity Slider." Drag the slider you want to use into that location. (If you don't see it, check that ApplySensitivity() on the ChangeSettings script is public, I added that as an edit later). Now if you want to do the button approach where you apply once you're ready, create a button and scroll down until you see "On Click ()" on the Button component. Click the + in the bottom right of the panel, and drag the Player GameObject into the new slot that appears. The "No Function" dropdown will then be enabled. Open that and look for ChangeSettings > ApplySensitivity(). However, if you want to do the realtime approach I mentioned where the sensitivity changes as the slider changes, look for the "On Value Changed ()" panel on the slider ins$$anonymous$$d and repeat the process for adding ApplySensitivity() from there. Contact me if you have any other questions!

avatar image ChompIV shrey150 · Jul 10, 2017 at 08:29 AM 0
Share

I copied your script and put it on my player, also applied your edit to first person controller to allow us to modify the private stuff, but in the Sensitivityslider slot (in the inspector) I cannot add my slider I want to use because it is on a different scene, I cannot drag it onto the slot because of it being in a different scene. And once that is resolved, how do I do the next step? Do I (on the main menu/options scene where the script is) create a on value change (use the + sign etc) and drag the ChangeSettings script you made onto that slot and then choose ApplySensitivity() ? Thats what I'm stuck on, and thank you so much for the help it means a ton!

Show more comments

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

72 People are following this question.

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

Related Questions

sensitivity slider/ drop down help 0 Answers

Get a float from a different GameObject? (MouseLook) 1 Answer

How to make a slider menu 1 Answer

MouseLook FPS Sensitivty (DropDown) 0 Answers

Slider value saving? 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