I wanna make a slider that controls the cameras sensitivity across scenes (like a slider in the menu that controls the cameras sensitivity in a different scene)
my camera control script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraControl : MonoBehaviour
{
public float sensitivity = 20f;
public Transform playerBody;
float xRotation = 0f;
void Start() {
Cursor.lockState = CursorLockMode.Locked;
}
void Update() {
float mouseX = Input.GetAxis("Mouse X") * sensitivity * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
playerBody.Rotate(Vector3.up * mouseX);
}
}
@ The video isn’t what I’m trying to do, it seems. I’m trying to access a variable from an object from a different scene, like a sensitivity slider in a settings menu scene that controls the cameras sensitivity in a different scene
Well, if you have both scenes loaded at the same time, then you just need to use GameObject.Find to find the slider. Or put the value in a static variable if you prefer that.
that should work I’ll try that, I might also use [DontDestroyOnLoad] and get the value of the slider. then I can replace the cameras float value with the value stored in the script