Hi I’m new can in unity scripting in C#.
I’m making my first game just a normal plat former but i am having that error when I try to run the game “Assets/PlayerMovement.cs(33,63): error CS1002: ; expected”
here is my code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Debug.Log("Hello from Start");
}
// Update is called once per frame
void Update()
{
if (Input,GetkeyDown("space"))
{Getcomponent<Rigidbody>().velocity = new Vector3(0,5,0);
}
if (Input.Getkey("up"))
{
GetComponent<Rigidbody>().velocity = new vector3(0,0,5);
}
if (Inpur.Getkey("right"))
{
GetComponent<RigidBìbody>().velocity = new vector3(5,0,0)
}
if (Input.Getkey("down"))
{
GetComponent<Rigidbody>().velocity = new vector3(0,0,-5);
}
if (Inpur.Getkey("left"))
{
GetComponent<RigidBìbody>().velocity = new vector3(-5,0,0)
}
}
}
The complete error message contains everything you need to know to fix the error yourself.
The important parts of the error message are:
the description of the error itself (google this; you are NEVER the first one!)
the file it occurred in (critical!)
the line number and character position (the two numbers in parentheses)
also possibly useful is the stack trace (all the lines of text in the lower console window)
Always start with the FIRST error in the console window, as sometimes that error causes or compounds some or all of the subsequent errors. Often the error will be immediately prior to the indicated line, so make sure to check there as well.
Look in the documentation. Every API you attempt to use is probably documented somewhere. Are you using it correctly? Are you spelling it correctly? Are you structuring the syntax correctly? Look for examples!
All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don’t have to stop your progress and fiddle around with the forum.
Remember: NOBODY here memorizes error codes. That’s not a thing. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.
If you get completely stumped…
How to report your problem productively in the Unity3D forums:
This is the bare minimum of information to report:
what you want
what you tried
what you expected to happen
what actually happened, log output, variable values, and especially any errors you see
links to documentation you used to cross-check your work (CRITICAL!!!)
The purpose of YOU providing links is to make our job easier, while simultaneously showing us that you actually put effort into the process. If you haven’t put effort into finding the documentation, why should we bother putting effort into replying?
Also, virtually every line where you are getting input is wrong: Input,Getkeydown should be Input.GetKeyDown Input.Getkey should be Input.GetKey Inpur.Getkey should be Input.GetKey
And other than the first time you use Vector3, every other time you have the capitalisation wrong. You keep putting new vector3 when it should be new Vector3
You need to slow down and type everything perfectly otherwise you will just keep coming back here with more issues which you should be able to find the solutions to in the manual/scripting api.
And I hope you are using a proper IDE for writing your scripts (not something like notepad) so then you should be getting both intellisense and underlines/highlighting of all of these spelling mistakes.
Excellent point BABIA… check this out OP… you want Intellisense or you’ll go insane:
This may help you with intellisense and possibly other Visual Studio integration problems:
Sometimes the fix is as simple as doing Assets → Open C# Project from Unity. Other times it requires more.
Other times it requires you also nuke the userprefs and .vsconfig and other crufty low-value high-hassle files that Visual Studio tends to slowly damage over time, then try the above trick.
Also, try update the package inside of Unity: Window → Package Manager → Search for Visual Studio Editor → Press the Update button
Depending on flavor and version of Visual Studio, it may also have an installation step that you perform within the actual Visual Studio. This step seems finicky at best and may require multiple openings of VS before it comes up.
Update: The VSCode extension has been deprecated and abandoned:
Recently (July 2023) I worked on a Windows11 system that required a Microsoft component to be installed from within Visual Studio before it would work properly with all the OTHER software installed under Unity. I have no documentation on that process as I have only seen it once and it surprised me as well.