- Home /
Question by
rose_among_thornes · Jul 12, 2016 at 08:01 AM ·
scripting problemscript.not workingdooropening
Door Script compiler error
I have written a script and every time I try to play the game I get a constant Error of 'error CS0103 : The name 'Global' does not exist in the current context'. I have been trying to fix this for the past few hours and have no idea why it isn't working. My script is:
// Use this for initialization
void Start ()
{
myAudio = GetComponent<AudioSource>();
myAudio.enabled = false;
}
IEnumerator DoorMotionCo(Vector3 target)
{
Vector3 targetInverse = new Vector3(-target.x,target.y,target.z);
while(Vector3.Distance(myDoor1.transform.localPosition, target) >= snapTo)
{
Debug.Log ("Door Running");
myDoor1.transform.localPosition = Vector3.Lerp(myDoor1.transform.localPosition, target, moveSpeed * Time.deltaTime);
myDoor2.transform.localPosition = Vector3.Lerp(myDoor2.transform.localPosition, targetInverse, moveSpeed * Time.deltaTime);
yield return null;
}
myDoor1.transform.localPosition = target;
myDoor2.transform.localPosition = targetInverse;
yield return null;
}
void OnTriggerEnter(Collider col)
{
if (col.gameObject.tag == "Player" && Global.haveKey01 == true)
{
StopCoroutine ("DoorMotionCo");
StartCoroutine("DoorMotionCo", new Vector3 (doorMove, 0f,0f));
myAudio.enabled = false;
myAudio.enabled = true;
}
}
void OnTriggerExit(Collider col)
{
if (col.gameObject.tag == "Player" && Global.haveKey01 == true)
{
StopCoroutine ("DoorMotionCo");
StartCoroutine("DoorMotionCo", Vector3.zero);
myAudio.enabled = false;
myAudio.enabled = true;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Door open script opens all the doors in the scene 3 Answers
Save GameObject to file without Playerpref 2 Answers
How can i keep the spawned objects to be inside a given area ? 2 Answers
How can i color a object material color using StartCoroutine ? 1 Answer
How can i highlight objects with the mouse when the mouse cursor is moving over objects ? 1 Answer