Question by
Dylan_the_nipple · May 17, 2016 at 01:07 AM ·
error messagereferenceclasses
An object reference is required to access non-static member `UnityEngine.Behaviour.enabled'
I am trying to model acceleration, and I have a separate script for it so that once it reaches a speed (200) it cancels the acceleration. However, I have no idea why it is giving me this error? Please help, im fairly new.
public class Movement : MonoBehaviour {
public float movespeed = 10f;
public class Accleration {}
void Update () {
if (Input.GetKey (KeyCode.W))
transform.Translate (Vector3.down * movespeed * Time.deltaTime);
if (movespeed > 200)
Acceleration.enabled = false;
}
} public class Acceleration : MonoBehaviour {
public class Movement {}
public float movespeed = 10f;
void Update () {
movespeed -= Time.deltaTime;
}
}
Comment
Your answer
Follow this Question
Related Questions
Help! Class problem. 2 Answers
Using a subclass in the inspector in place of a parent class and accessing the subclass variables 1 Answer
How can I solve this? 0 Answers
object reference is required to access non-static member - What does this mean? 1 Answer
NullReferenceExeption when I use Mask 0 Answers