- Home /
error CS8025: Parsing error (sorry)
Hello guys, I know this is a common mistake that circulates around here the more I wanted to know how to fix this script:
using UnityEngine; using System.Collections;
public class ControladorPersonagem : MonoBehaviour {
public CharacterController CharacterController;
public float characterSpeed;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(Input.GetKey(KeyCode.RightArrow))
{
//meu carinha vai andar para a direita
CharacterController.Move(new Vector3(characterSpeed,0,0)*Time.deltaTime);
}//
if(Input.GetKey(KeyCode.LeftArrow))
{
CharacterController.Move(new Vector3(-characterSpeed,0,0)*Time.deltaTime);
}
I know this has been discussed before here on the forum but I still do not understand how these objects are application, sorry my english. ty :3
Would be great if you paste the whole script with proper indentation. Also, specify the line where it fails and some description. As I see you're having syntactic problems that are not referred with Unity itself but with C# understanding. This script won't compile as it's at least leaking some closing brackets }
at the end to close if statement and Update method. Also, calling a field the same way as its class is not possible in this case, so it will give you problems.
How would indentation Sorry I'm not very good with scripts D? The line that the problem is
if (Input.Get$$anonymous$$ey ($$anonymous$$eyCode.LeftArrow))
Sorry for noob questions have several more things I want to ask questions.
what happens is that I try to play in Unity to test the left arrow and it does the following problem:
Scrit:
Error:
@frarees's comment indicated the problem with your script.
You are missing two closing brackets at the end of the file
You should not have a variable the same name as the class. Typically the Class will use an upper case starting letter where the variable will use a lower case letter. Here is your script with the two changes @frarees indicated:
using UnityEngine; using System.Collections;
public class ControladorPersonagem : $$anonymous$$onoBehaviour {
public CharacterController characterController; public float characterSpeed; // Use this for initialization void Start () { } // Update is called once per frame void Update () { if(Input.Get$$anonymous$$ey($$anonymous$$eyCode.RightArrow)) { //meu carinha vai andar para a direita characterController.$$anonymous$$ove(new Vector3(characterSpeed,0,0)*Time.deltaTime); }// if(Input.Get$$anonymous$$ey($$anonymous$$eyCode.LeftArrow)) { characterController.$$anonymous$$ove(new Vector3(-characterSpeed,0,0)*Time.deltaTime); } } }
Answer by frarees · Jan 11, 2014 at 01:03 PM
I highly recommend you to stop posting every problem that you face and instead start discovering the tools you're gonna use i.e. Unity and C#. We cannot solve things for you because you don't even barely know what is going on. We all had to start from scratch once. I recommend you to watch the beginner level tutorials that Unity offers for free, as well as some C# related tutorials.
Frarees is right you should learn the basics first and then face us with the problems you have these problems you deal with are mostly syntax errors.
Answer by NutellaDaddy · Jan 11, 2014 at 04:54 AM
You need one more closing bracket. It's pretty simple but I'm glad to see people getting interested in scripting.
Answer by Infinite_Gamer · Jan 11, 2014 at 05:08 AM
I am new to this too but I think that this could help... I hope
By the way this script does not need the characterController
and I think this can work as its own script right now just copy/paste
//Variables Start
//Public Variables
public int PlayerSpeed = 20;
//Private Variables
private Transform myTransform;
//Variables End
// Use this for initialization
void Start () {
myTransform = transform;
}
// Update is called once per frame
void Update () {
//move the player left and right
myTransform.Translate(Vector3.right * PlayerSpeed * Input.GetAxis("Horizontal") * Time.deltaTime);
}
Again Hopes this helps you :D
Infininite Gamer
Answer by blaziken · Jan 11, 2014 at 11:43 AM
I followed all the tips and I thank you for them. Decided the following script that the Infinite Gamer despite being good for me is not going to help me continue to video lesson that I see and in which the teacher marked that way the script:
using UnityEngine;
using System.Collections;
public class ControladorPersonagem : MonoBehaviour {
public CharacterController characterController;
public float characterSpeed;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(Input.GetKey(KeyCode.RightArrow))
{
//meu carinha vai andar para a direita
characterController.Move(new Vector3(characterSpeed,0,0)*Time.deltaTime);
}//
if(Input.GetKey(KeyCode.LeftArrow))
{
characterController.Move(new Vector3(-characterSpeed,0,0)*Time.deltaTime);
}
}
}
Ok, everything worked fine but the following error appeared to me:
Please forgive me for the noob questions but I unfortunately did not do well adequei even the interface in English or the scripts that are new to me, thanks for the understandability and again sorry.
You have to assign characterController
from the inspector or from some other script. Otherwise it will contain a reference to null. Try not to add more questions as answers.
It worked very well, thank you <3 Sorry for posting in the wrong area and am very grateful for the quick support of people from the forum.Ty <3
Your answer
Follow this Question
Related Questions
c# parsing error Help please and the error is at where it says public string Name 1 Answer
CS8025 Error (Parsing Error) 1 Answer
I keep getting CS8025 parsing error 1 Answer
CS8025 Parsing error 3 Answers
CS8025 parsing error 1 Answer