Hello, I'm a JavaScript user, and I need to change a C# script (its the MouseLook Unity have).
What I need to do is it access a boolean from another script, but it keeps saying '..required to access non static ..'
I need to access the headLock boolean (to make it static), how would I go about doing that:
using UnityEngine;
using System.Collections;
[AddComponentMenu("Camera-Control/Mouse Look")]
public class MouseLook : MonoBehaviour {
public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
public RotationAxes axes = RotationAxes.MouseXAndY;
public float sensitivityX = 15F;
public float sensitivityY = 15F;
public float minimumX = -360F;
public float maximumX = 360F;
public float minimumY = -60F;
public float maximumY = 60F;
float rotationY = 0F;
public bool headLock = false;
void Update ()
{
if (axes == RotationAxes.MouseXAndY && headLock == false)
{
float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX;
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
}
else if (axes == RotationAxes.MouseX && headLock == false)
{
transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0);
}
else if (headLock == false)
{
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y, 0);
}
if(Input.GetButton("Jump")){
headLock = true;
print("headLock = true");
}
else{
headLock = false;
print("headLock = false");
}
}
void Start ()
{
// Make the rigid body not change rotation
if (rigidbody)
rigidbody.freezeRotation = true;
}
}