I was following one of the video tutorials for building a stealth game. In the c# script lastPlayerSighting I keep getting a parser error: unexpected symbol ‘panicAudio’ even though it’s been declared as a private audioSource.
using UnityEngine;
using System.Collections;
public class lastPlayerSighting : MonoBehaviour
{
public Vector3 position = new Vector3(1000f, 1000f, 1000f);
public Vector3 resetPosition = new Vector3(1000f, 1000f, 1000f);
public float lightHightIntensity = .25f;
public float lightlowIntensity = 0f;
public float fadeSpeed = 7f;
public float musicFadeSpeed = 1f;
private alarmLight alarm;
private Light mainLight;
private AudioSource panicAudio;
private AudioSource[] sirens;
void awake()
{
alarm = GameObject.FindGameObjectWithTag(tags.alarm).GetComponent<alarmLight>();
mainLight = GameObject.FindGameObjectWithTag(tags.mainLight).light
panicAudio = transform.Find ("secondaryMusic").audio;
GameObject[] sirenGameObjects = GameObject.FindGameObjectsWithTag(tags.siren);
sirens = new AudioSource[sirenGameObjects.Length];
for (int i = 0; i < sirens.Lenght; i++)
{
sirens _= sirenGameObjects*.audio;*_
* }*
* }*
* void update()*
* {*
* switchAlarms();*
* musicFading();*
* }*
* void switchAlarms()*
* {*
* alarm.alarmOn = (position != resetPosition);*
* float newIntensity;*
* if(position != resetPosition)*
* {*
* newIntensity = lightlowIntensity;*
* }*
* else*
* {*
* newIntensity = lightHightIntensity;*
* }*
_ mainLight.intensity = Mathf.Lerp(mainLight.intensity, newIntensity, fadeSpeed * Time.deltaTime);_
* for(int i = 0; i < sirens.Length; i++)*
* {*
_ if(position != resetPosition && !sirens*.isPlaying)
{
sirens.Play();
}
else if(position == resetPosition)
{
sirens.Stop ();
}
}
}*_
* void musicFading()*
* {*
* if(position != resetPosition)*
* {*
_ audio.volume = Mathf.Lerp(audio.volume, 0f, musicFadeSpeed * Time.deltaTime);
panicAudio.volume = Mathf.Lerp(panicAudio.volume, 0.8f, musicFadeSpeed * Time.deltaTime);
* }
else*
* {
audio.volume = Mathf.Lerp(audio.volume, 0.8f, musicFadeSpeed * Time.deltaTime);
panicAudio.volume = Mathf.Lerp(panicAudio.volume, 0f, musicFadeSpeed * Time.deltaTime);
}
}*_
}