How to get the Slider Value and add it to a different Float or Int.

Greetings,

Anyone know how i can connect my mouseSens Float to my Slider UI which then controlls the mouseSens Value.

So, i have a Slider and 2 Scripts.
1 Script is responsible for the Movement of the Camera (CameraController),
The CameraController has the MouseSens in it.

2 Script is responsible for all the Settings Stuff that are in my Settings Menu.
In it is the Slider and the int SensSlider.

The SensSlider is the int which will get the Value of the Slider and so change the MouseSens via Playerprefs.

Here a Screenshot of my Slider Settings.

Now the Code that is Responsible to do it, but i can’t get it right and don’t know how to.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class CameraController : MonoBehaviour
{
    float mouseSens;

    private void Start()
    {
        PlayerPrefs.SetFloat("mouseSens", 1000f);
    }

    private void Update()
    {
        mouseSens = PlayerPrefs.GetFloat("mouseSens");
    }

}

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class SettingsMenu : MonoBehaviour
{
    public Slider slider;

    public int SensSlider;

    private void Update()
    {
        slider.value = value;
        
        PlayerPrefs.GetFloat("mouseSens");
        PlayerPrefs.SetFloat("mouseSens", SensSlider);
    }

}

Just a small fixing required in your SettingsMenu script…

public class SettingsMenu : MonoBehaviour
 {
     public Slider slider;
     public int SensSlider;
 
     private void Update()
     {
         SensSlider = slider.value:
         PlayerPrefs.SetFloat("mouseSens", SensSlider);
     }
 
 }

And that should do it, what you were doing is taking slider.value and setting it to a non existent variable value…and then taking mouseSens and setting it to SensSlider, which is 0(which is serialized)… instead you had to actually set SensSlider to slider.value and mouseSens to SensSlider…hope this helps