Hey I just started using unity today and would like advice/solutions to the last error I am facing as I can’t seem to solve the issue no matter what tutorials or threads I listened to.
using UnityEngine;
using static System.Net.Mime.MediaTypeNames;
public class PlayerController : MonoBehaviour;
{
public float speed;
public Text countDisplay;
public Text winText;
private int count;
private Rigidbody rb;
Always use the buttons to wrap your code in tags that will preserve formatting and make things easier to read.
The 4 in the error message “Assets\Scripts\PlayerController.cs(4,47)” refers to the line on which the compiler got confused. It thinks a comma would be valid where it found something else. What you have on line 4 ends with a semicolon, where there should not be a semicolon. You don’t need a comma, but you can’t have a semicolon there.
If you’re following a tutorial, until you have some experience with C# syntax, you will need to be ultra-vigilant about every single character you type. Over time you will understand the purpose of the semicolons or braces and will make little mistakes like this less often.
thanks for the advice, however i am encountering 2 additional errors once i remove the semicolon called 'Assets\Scripts\PlayerController.cs(7,17): error CS0723: Cannot declare a variable of static type ‘MediaTypeNames.Text’
Here is a screenshot of the error message:
Well. That just means you have more things to fix.
As a beginner its common to make stupid mistakes of missing commas, semi colons, casing of everything, spelling mistakes of even your own variables etc. however. The compiler does give you good hints on whats wrong and as it is your code you should understand what it does enough to be able to look at what the compiler says is wrong and look to fix it.
you should not expect to come to a website every time you get it wrong and have someone fix it. Or you never truly learn
in this case it seems you have confused it by having 2 classes called Text available and its picked one, and its problably the wrong one.
Thanks for the advice, since it’s my first time I probably made some dumb mistake along the way. I’ll try follow the compiler and see what mistakes I can fix, thank you!