using UnityEngine;
public class FĂśljspelare : MonoBehaviour
{
public Transform Player;
public vector3
// Update is called once per frame
void Update()
{
transform.position = Player.position;
}
}
the error i get
Assets\Scenes\Fďż˝ljspelare.cs(11,5): error CS1519: Invalid token âvoidâ in class, struct, or interface member declaration
Just to make sure you understand what went wrong, there were actually 2 problems with your code example.
Capital letters matter, so vector3 does not exist, but Vector3 does.
You did not specify a name for that variable, nor did you end the line with a semicolon. Thatâs why the error was confused about âvoidâ - from its perspective you wrote âpublic vector3 void Update()â, which makes no sense. Spaces and newlines are only there for you, they dont exist from the compilers point of view. So things need to be either enclosed in curley brackets (classes, methods, âŚ) or ended with a semicolon (declarations, most other things).
While iâm at it, you may wanna follow common coding conventions:
Naming conventions mostly use camelCase, meaning you capitalize the letter of each new word in the string. For most things (variables and such), start with a lower case letter. So âPlayerâ should be âplayerâ. Methods, Classes and Properties however should be defined in upper camel case, starting with a capital letter.
It is bad practice to use language specific letters like âĂśâ for anything other than in comments.
It is generally adviced to write code in english, since most of the methods you use are english anyways (consistency) and it helps others understanding your code better, which is especially important when you are going to post it online for help. Technically this includes comments, but thatâs rather a nice to have.