so I'm new to Unity and I've been trying to test the scene with the script attatched to a character. However, it keeps saying "The associated script cannot be loaded. Please fix any compile errors and assign a valid script." It also says that the name of the file could be different from the name in the code but it isnt, and also it says that the code could be missing MonoBehaviour Scripts. It wont even allow me to attach the script to characters because it cant find the script class.
I've copied and downloaded character movement codes from the internet but they didnt work either. I've also tried deleting and re-making the CS files but that didnt work either. Even adding empty scripts to characters didnt work unless i do it from "Add component"
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Movement : MonoBehaviour { SpriteRenderer sprite; Rigidbody2D rigid; // Start is called before the first frame update void Start() { sprite = GetComponent<SpriteRenderer>(); rigid = GetComponent<Rigidbody2D>(); } private void FixedUpdate() { if (Input.GetKey("d")) rigid.velocity = new Vector2(2, 0); else if (Input.GetKey("a")) rigid.velocity = new Vector2(-2, 0); } } There are also these errors in Unity if that helps
