Error says Assets/scripts/DoorManager.cs(8,10): error CS1519: Unexpected symbol `public’ in class, struct, or interface member declaration
My code:
using UnityEngine;
using System.Collections;
public class DoorManager : MonoBehaviour {
public bool doorIsOpen = false;
public float doorTimer = 0.0f;
public float doorOpenTime = 3.0f
public AudioClip doorOpenSound;
public AudioClip doorShutSound;
// Use this for initialization
void Start () {
doorTimer = 0.0f;
}
// Update is called once per frame
void Update () {
if(doorIsOpen){
doorTimer += Time.deltaTime;
if(doorTimer > doorOpenTime){
DoorManager(doorShutSound, false, "doorshut");
doorTimer = 0.0f;
}
}
}
void DoorCheck(){
if(!doorIsOpen){
Door(doorOpenSOund, true, "dooropen");
}
}
void Door(DudioClip aClip, bool openCheck, string AnimName){
AudioClip.PlayOneShot(AudioClip);
doorIsOpen = openCheck;
tranform.parent.gameObject.animation.Plat(animName);
}
}
What can i do?
Line 4 needs a ; at the end.
public float doorOpenTime = 3.0f;
When you do this you’ll notice just how broken the rest of this script is.
I must be feeling generous today. Here’s your corrected code. It compiles without error but I’ve not actually run it and I have no idea if it does what you wanted it to do. I see you’re tied up in a renman thing atm (hella good luck with that).
using UnityEngine;
using System.Collections;
public class DoorManager : MonoBehaviour
{
public bool doorIsOpen = false;
public float doorTimer = 0.0f;
public float doorOpenTime = 3.0f;
public AudioClip doorOpenSound;
public AudioClip doorShutSound;
// Use this for initialization
void Start ()
{
doorTimer = 0.0f;
}
// Update is called once per frame
void Update ()
{
if(doorIsOpen)
{
doorTimer += Time.deltaTime;
if(doorTimer > doorOpenTime)
{
Door(doorShutSound, false, "doorshut");
doorTimer = 0.0f;
}
}
}
void DoorCheck()
{
if(!doorIsOpen)
{
Door(doorOpenSound, true, "dooropen");
}
}
void Door(AudioClip aClip, bool openCheck, string AnimName)
{
audio.PlayOneShot(aClip);
doorIsOpen = openCheck;
transform.parent.gameObject.animation.Play(AnimName);
}
}