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;
}
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;
}
}