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!!!
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