If statement randomly not working

I have this if statement, set up the same way as all my other ones (near the bottom), but it’s not working. Why?

using UnityEngine;
using System.Collections;

public class CameraController : MonoBehaviour {

    public GameObject pBody;

    public Vector3 offset;

    public static bool Increase;

    // Use this for initialization
    void Start() {

        Increase = false;

        offset = transform.position - pBody.transform.position;

    }

    // Update is called once per frame
    void Update() {

        transform.position = pBody.transform.position + offset;

    }

    if (Increase == true){

        //some action

    }

}

I keep getting these errors:

  1. Assets/Scripts/CameraController.cs(30,6): error CS1519: Unexpected symbol `if' in class, struct, or interface member declaration
    
  2. Assets/Scripts/CameraController.cs(30,19): error CS1519: Unexpected symbol `==' in class, struct, or interface member declaration
    
  3. Assets/Scripts/CameraController.cs(36,1): error CS8025: Parsing error
    

I'll take a look at these.

2 Answers

2

your if block is outside of the Update function

Because it’s not contained within a method. Is it meant to be in Update? Check your brackets.

Wow. I completely overlooked that. I guess it's just luck my other if statements have been in a method.