Quantcast
Channel: Questions in topic: "playerprefs"
Viewing all articles
Browse latest Browse all 1333

Get a float from a different GameObject? (MouseLook)

$
0
0
I need to access a public float from the fps controller's mouselook script. I think it is on the player? It is accessed from FirstPersonController script like it is in a drop down in the inspector. It is [Serializable]. Why doesnt this work? (im a noob and need help making a sensitivity slider and I cannot find it anywhere, if anyone has a script for that (FPSController) I would love to have it. How do i access the float? (My scirpt): using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityStandardAssets.Characters.FirstPerson; public class sensitivitySliderScript : MonoBehaviour { [SerializeField] public MouseLook m_MouseLook; public float xfloat; private void Start() { xfloat = MouseLook.XSensitivity; } void Update () { // PlayerPrefs.SetFloat("currentX", MouseLook.XSensitivity); // MouseLook.XSensitivity = PlayerPrefs.GetFloat("currentX", 0); } } MouseLook floats I need: using System; using UnityEngine; using UnityEngine.UI; using UnityStandardAssets.CrossPlatformInput; namespace UnityStandardAssets.Characters.FirstPerson { [Serializable] public class MouseLook { public float XSensitivity = 2; public float YSensitivity = 2;

Viewing all articles
Browse latest Browse all 1333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>