EDIT: I accidentaly created a new public class named MonoBehaviour so this was my own fault and it is fixed now. Thanks to everyone who tried to help.
Can someone please explain to me why this code is giving me the error "CS0103: The name ‘transform’ does not exist in the current context’ in Visual Studio?
using UnityEngine;
using System.Collections;
public class test : MonoBehaviour {
// Use this for initialization
void Start () {
transform.position = Vector3.zero;
}
// Update is called once per frame
void Update () {
}
}
I created this class as a test but I have multiple other classes that give me the same error in Visual Studio and in Unity as well. Some months ago the project worked perfectly fine.
EDIT:
After restarting, the error now doesn’t show up in Unity anymore and I can add the affected scripts to a GameObject again but the error is still present in VisualStudio.
EDIT 2:
It reappeared in Unity after I changed the name of the test class and it’s file. But it only appeared for the test class.