Why does it say "Assets\Scripts\PlayerFollow.cs(26,10): error CS1002: ; expected"?

Here is my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerFollow : MonoBehaviour
{
    public GameObject player;
    private Vector3 offset;
    private bool switch;
    // Start is called before the first frame update
    void Start()
    {
      
    }
    // Update is called once per frame
    void LateUpdate()
    {
        switch = Input.GetButton("Fire1");
        if (switch == true)
        {
            offset = new Vector3(0, 2, 1);
        }
        else
        {
            offset = new Vector3(0, 8, -7.5f);
        }
        transform.position = player.transform.position + offset;
    }
}

The problem might be here private bool switch;. “switch” is a reserved keyword with a special meaning. Change that to another name and you should be fine.

1 Like

It worked! Thanks for the help!