- Home /
Duplicate Question - cs8025 covered many times
How do i fix this CS8025 Parsing Error?
Hi! Please do not laugh but I am having trouble with this ONE problem I am NOT a coder at all because I do level design and the like, so here is my problem I wanted to try and make a NPC follow my player so I put together this that I have found but seems to be an incomplete script because I get one error.. first here is the code:
{ if (Vector3.Distance(target.position, myTransform.position) > maxdistance);
// Get a direction vector from us to the target
Vector3 dir = target.position - myTransform.position;
1. // Normalize it so that it's a unit direction vector dir.Normalize(); // Move ourselves in that direction myTransform.position += dir moveSpeed Time.deltaTime;
Then, here is my one error message,
Assets/follow_script.cs(1,1): error CS8025: Parsing error
What did I do wrong??
Thank You!!!
Answer by smallbit · Jul 24, 2015 at 03:13 AM
you need to paste entire code here because its a little bit confusing. Parsing error is due to the fact that you are missing "}" bracket, my confusion is whether your "{" bracket comes from another if or a method or it is suppose to be for the if, or its just not needed at all and your if statement executes just 1 line of code. Also putting semicolon ";" in the end of if statement will cause it to execute every time so you better remove it too;
try this in case you have 1 line of code
if (Vector3.Distance(target.position, myTransform.position) > maxdistance)
Vector3 dir = target.position - myTransform.position;
or this if you execute more code there
if (Vector3.Distance(target.position, myTransform.position) > maxdistance)
{
Vector3 dir = target.position - myTransform.position;
}
so first try just removing "{" from start of first line, or post entire script here if its not solving problem for you
Well I did this and I think it's kind of narrowed down with the help you gave me but there is still just one parsing error here is the whole code I tried.. I also tried removing the brackets but to no avail it still comes up with an error? Really Thankful For Your Continual Help! =)
if (Vector3.Distance(target.position, myTransform.position) > maxdistance)
{ // Get a direction vector from us to the target
Vector3 dir = target.position - myTransform.position;
// Normalize it so that it's a unit direction
vector dir.Normalize();
// $$anonymous$$ove ourselves in that direction
myTransform.position += dir moveSpeed Time.deltaTime;
Vector3 dir = target.position - myTransform.position;
vector dir.Normalize();
This line makes no sense. Perhaps you meant:
dir.Normalize();
I assume you wanted to multiply these values and lost your astericies.
myTransform.position += dir * moveSpeed * Time.deltaTime;
You're also trying to declare the dir vector twice.
Vector3 dir = foo;
Vector3 dir = bar;
This is improper. Declare it once:
Vector3 dir = foo;
dir = bar;
You're missing the closing curly brace for this IF conditional block
Hang on... "here is the whole code" - so you don't have a class declaration? No functions? No using UnityEngine
?
Please read my first line tanoshimi.. I am NOT a coder.... I'll try to work with it and see what I come up with AlwaysSunny.. Thank You For The Help and will be back if I get more errors.
Follow this Question
Related Questions
add two compile instruction into "smcs.rsp",lead to internal compile error! 2 Answers
whats wrong with this code for a menu 3 Answers
Parsing error 0 Answers
parsing error on c# do not destroy code 1 Answer
CS8025 Parsing Error Please Help 1 Answer