I’m working on a fps, and I have a sniper rifle that can zoom up on enemies. But It’s to sensitive to try to snipe enemies from a distance. So, I made a .js script that looks like this:
function Update () {
if (Input.GetKeyDown("3")) {
MouseLook.sensitivityX = 7;
MouseLook.sensitivityY = 1;
}
}
Then on my MouseLook script (which is in C# [I didn’t write it]) changed the variables from this:
public class MouseLook : MonoBehaviour {
public float sensitivityX = 15F;
public float sensitivityY = 15F;
To this:
public class MouseLook : MonoBehaviour {
public static float sensitivityX = 15F;
public static float sensitivityY = 15F;
A null reference error means the object you’re trying to refer to doesn’t exist. If you have problems figuring out what’s causing the issue, try breaking it into parts instead of doing everything on one line.