- Home /
Question by
gusg_ · Nov 17, 2016 at 07:19 AM ·
syntax-error
Brackets error. I cant find an unclosed one
I'm a Unity noob and Microsoft VS is screaming at me saying I don't have a closed bracket on this code: using UnityEngine; using System.Collections;
public class ObjectUnder : MonoBehaviour {
// Use this for initialization
public void Start () {
public bool underwater = false;
}
// Update is called once per frame
void Update () {
underwater = transform.position.y < 5.9;
}
}
Comment
Best Answer
Answer by brunocoimbra · Nov 17, 2016 at 04:59 AM
The problem is the "public bool underwater = false;", you can't use the "public" keyword inside a method. The correct script would be:
using UnityEngine;
using System.Collections;
public class ObjectUnder : MonoBehaviour {
public bool underwater;
// Use this for initialization
public void Start () {
underwater = false;
}
// Update is called once per frame
void Update () {
underwater = transform.position.y < 5.9;
}
}
Your answer
Follow this Question
Related Questions
Limit rotation for a statue puzzle 1 Answer
error help 2 Answers
Object reference woe? 1 Answer
error CS1520: Class, struct, or interface method must have a return type 2 Answers