- Home /
How to fix Script? error CS1525: Unexpected symbol `Internal'
I get Assets/Scriptshas/EnemyAI.cs(29,71): error CS1525: Unexpected symbol `'
using UnityEngine;
using System.Collections;
public class EnemyAI : MonoBehaviour {
public Transform target;
public int moveSpeed;
public int roatationSpeed;
private Transform myTransform;
void Awake(){
myTransform = transform;
}
// Use this for initialization
void Start () {
GameObject go = GameObject.FindGameObjectWithTag("Player");
target = go.transform;
}
// Update is called once per frame
void Update () {
Debug.DrawLine (target.position, myTransform.position, Color.yellow);
//Look at target
myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed * Time.deltaTime);
}
}
Problem is between myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed * Time.deltaTime); Which is line 29 in my script, thank you for your time!
Can't say from this limited amount of information. Edit the question to include the rest of the script along with the actual error message. And place a comment on the line where the compiler indicates there is an error.
Did you mean to mark a variable as internal, but it has a capital I ins$$anonymous$$d of lower case internal?
It appears you have some funky characters in your line:29, i would delete the highlighted parts in the image and type them out again, rebuild the scripts and see if that helps.
I retyped the line and got 3 new errors.
Assets/Scriptshas/EnemyAI.cs(29,144): error CS0103: The name rotationSpeed' does not exist in the current context Assets/Scriptshas/EnemyAI.cs(29,51): error CS1502: The best overloaded method match for
UnityEngine.Quaternion.Slerp(UnityEngine.Quaternion, UnityEngine.Quaternion, float)' has some invalid arguments
Assets/Scriptshas/EnemyAI.cs(29,51): error CS1503: Argument #3' cannot convert
object' expression to type `float'
Answer by robertbu · Mar 11, 2013 at 06:01 PM
If you past your code into an word processor or editor that shows symbols, or you do a hexdump, you will find a symbol between 'target' and '.position' on that line. Hex value is AC, and probably inserted by a word processor. The fix is to delete the line and retype it.
It worked for me.
The problem was that I copied an line from an PDF file and some special symbols may have come together.
Thank you!
Answer by Statement · Mar 11, 2013 at 04:31 PM
MSDN: Compiler Error CS1525
Perhaps you named a variable "internal" like this?
// error CS1525: Unexpected symbol `internal',
// expecting `.', `?', `[', `<operator>', or `identifier'
float internal = 4;
internal
is a reserved keyword. Consider renaming your symbol to something else in such case.
Answer by tataygames · Jul 31, 2019 at 02:17 AM
DAMN, I spend hours, searching for answers, this f*ng copy paste ruin my time. if you copy your code and paste it in other, and copy it back again to your code. this f* error will come up.