HOW TO FIX?

I was scripting when i found this error:error CS1519: Invalid token ‘=’ in class, struct, or interface member declaration

thise is the script :confused:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class visuale : MonoBehaviour
{
public Transform player;
float sensibilità = 300f;
float rotazione;

// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
} Cursor.visible = false
// Update is called once per frame
void Update()
{
float x = Input.GetAxis(“Mouse X”) * Time.deltaTime * sensibilità;
float y = Input.GetAxis(“Mouse Y”) * Time.deltaTime * sensibilità;
rotazione -= y;
rotazione = Mathf.Clamp(rotazione, -60f, 60f);
transform.localRotation = Quaternion.Euler(rotazione, 0, 0);
player.Rotate(Vector3.up * x);
}
}

That weird whacky à character on the end is totally illegal in identifiers. Replace it.

I also recommend naming things in English if you expect to need support in an English speaking forum.

Of course it is entirely up to you, you are welcome to suffer with people unable to help you with non-English code.

1 Like

Also use CODE tags as it is described here . And put your commands back inside your methods.

2 Likes

Please review the rules before creating another thread.

  • don’t create multiple threads
  • use descriptive titles
  • use code tags
  • don’t create low-effort posts. (example posting some code and asking for a fix).

There is a learn section on this site, I would recommend going through the tutorials and lessons there. You have posted a very common error, an error that describes what the problem is and what line it is on. This is VERY important, because you have a declaration outside of a method.

It actually isn’t illegal. Any UNICODE character is fine. “à” is fine in a variable name.

1 Like

My understanding is C# is supposed to have full unicode support for identifiers. Though I have never tried, so can’t say for sure. Unity frequently has regressions around special characters, so I just don’t ever use them outside of the contents of a string.

https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/identifier-names

I believe the real issue here is the “} Cursor.visible = false” line, where this code is just floating out in space without making any sense. But the OP didn’t provide the line number, so can’t say. @ already pointed this out though.

I have had to work with Unity (c#) code containing russian, chinese and korean characters on various project. Given I only speak 'Merican, it is a bit challenging debugging sometimes. :wink: But Unity and whatever ide you use will handle it.
(shaders are different story… grrrr)

1 Like

Honestly, I don’t really care what supposed to be legal identifier officially. If someone comes here to ask for help and I need to identify what’s happening, I don’t want to google translate every single variable name so I maybe get some info out of it. It is this simple. I personally think using non-English identifiers in a project is plain dumb. You never know who needs to continue the work on your code next, especially if it isn’t a pet-project at home. But maybe I just worked too long in international teams…

2 Likes

I stand corrected Uncle Joe and Zombie G… I know I’ve used compilers (probably not C#) that choked on anything outside of ASCII.

And don’t even get me started on invisible BOM headers lurking innocently in JSON.

“WHAT DO YOU MEAN INVALID JSON!? IT’S FINE!”

Regards,
Kurt “Eight Dot Three IS PLENTY!” Dekker

1 Like