- Home /
The question is answered, right answer was accepted
CS8025 Parsing error
Im getting an error that says: Assets/Scripts/EnemyAI.cs(35,9): error CS8025: Parsing error and i dotn know whats causing it so please help me :)
here is my code: using UnityEngine; using System.Collections;
public class EnemyAI : MonoBehaviour { public Transform target; public int moveSpeed; public int rotationSpeed; public int maxDistance;
private Transform myTransform;
void Awake() { myTransform = transform;
}
// Use this for initialization void Start () { GameObject go = GameObject.FindGameObjectWithTag("Player");
target = go.transform;
maxDistance = 2;
}
// 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);
if(Vector3.Distance(target.position, myTransform.position) > maxDistance) {
//move towards target
myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
}
}
Sorry this is wrong turns out it was a unity error i restarted unity and now it works fine :)
Answer by Statement · Jan 29, 2011 at 02:25 PM
public class EnemyAI : MonoBehaviour { // ...
void Awake()
{
// ...
}
void Start ()
{
// ...
}
void Update ()
{
// ...
}
} // <- You are missing one of these.
Reformatting the code so it's easier to read shows that you are missing a curly bracket to close the class.
thanks i already found that out after looking there and saying to my self "hmm should i put curly brackets there?" for 5 $$anonymous$$s but thanks anyway :)
Answer by koby2010 · Mar 10, 2013 at 05:26 AM
I need help My program wont work! This is it
using UnityEngine;
using System.Collections;
public class shooter : MonoBehaviour {
public Rigidbody bullet;
public float power = 1500f;
public float moveSpeed = 2f;
void Update () {
float h = Input.GetAxis("Horizontal") * Time.deltaTime * moveSpeed;
float v = Input.GetAxis("Vertical") * Time.deltaTime * moveSpeed;
transform.Translate(h, v, 0);
if(Input.GetButtonUp("Fire1")){
Rigidbody instance = Instantiate(bullet, transform.Position, transform.Rotation) as Rigidbody;
Vector3 fwd = transform.TransformDirection(Vector3.forward);
instance.AddForce(fwd * power);
}
}
well this isent an anser but i had the same problem with the error and i dont feel like restarting it and doing the code all over again what does pasing $$anonymous$$EAN!!!!!!!!!!!!!!!!!!
There are more than enough answers on UA about CS8025. Please don't make yet another question for it. In fact this question should be closed for being a duplicate. I would, but I don't have the priveliges.
Answer by mcgrewjosh98 · Nov 03, 2015 at 08:59 PM
This is the Error that I am getting: Assets/Plugins/GameManager.cs(127,4): error CS8025: Parsing error
I have no idea what is wrong and I don't have any kind of knowledge in JS or C#.
using UnityEngine; using System.Collections; using System.Collections.Generic;
public class GameManager : Photon.MonoBehaviour {
public GUISkin skin;
public Transform playerPrefab;
public static Transform localPlayer;
public static List<Transform> players = new List<Transform>();
public static Transform GetClosestPlayer(Vector3 fromPos)
{
Transform close = null;
float dist = -1;
foreach (Transform tra in players)
{
if (tra == null)
{
continue;
}
float thisD = Vector3.Distance(tra.position, fromPos);
if (dist == -1 || thisD < dist)
{
dist = thisD;
close = tra;
}
}
return close;
}
public static void AddPlayer(Transform tra)
{
players.Add(tra);
}
public static void RemovePlayer(Transform tra)
{
players.Remove(tra);
}
void Awake()
{
if (Application.loadedLevel < 1)
{
Debug.LogError("Configuration error: You have not yet added any scenes to your buildsettings. The current scene should be preceded by the mainmenu scene. Please see the README file for instructions on setting up the buildsettings.");
return;
}
//PhotonNetwork.sendRateOnSerialize = 10;
//PhotonNetwork.logLevel = NetworkLogLevel.Full;
//Connect to the main photon server. This is the only IP and port we ever need to set(!)
if (!PhotonNetwork.connected || PhotonNetwork.room == null)
{
Application.LoadLevel(0);
return;
}
PhotonNetwork.isMessageQueueRunning = true;
//Spawn our local player
GameObject GO = PhotonNetwork.Instantiate(playerPrefab.name, transform.position, Quaternion.identity, 0);
localPlayer = GO.transform;
}
void OnGUI()
{
GUI.skin = skin;
GameGUI();
}
bool showDebug = false;
void Update()
{
if (Input.GetKeyDown(KeyCode.Q))
showDebug = !showDebug;
if (Input.GetKeyDown(KeyCode.Escape))
{
Application.Quit();
}
}
/// <summary>
/// Check if the game is allowed to click here (for starting FIRE etc.)
/// </summary>
/// <returns></returns>
public static bool GameCanClickHere()
{
List<Rect> rects = new List<Rect>();
rects.Add(new Rect(0, 0, 110, 55));//Topleft Button
rects.Add(new Rect(0, Screen.height - 35, 275, 35));//Chat
Vector2 pos = new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y);
foreach (Rect re in rects)
{
if (re.Contains(pos))
return false;
}
return true;
}
void GameGUI()
{
GUILayout.Space(32);
if (GUILayout.Button("Leave"))
{
PhotonNetwork.LeaveRoom();
Application.LoadLevel(Application.loadedLevel + 1);
}
if (showDebug)
{
GUILayout.Label("isMasterClient: " + PhotonNetwork.isMasterClient);
GUILayout.Label("Players: " + PhotonNetwork.playerList.Count);
GUILayout.Label("Ping: " + PhotonNetwork.GetPing()
)
;
}
Follow this Question
Related Questions
Errors CS1525 and CS8025.... 1 Answer
Script Errors with C# 1 Answer
CS8025 Error (Parsing Error) 1 Answer
Parsing error with my code 3 Answers
Parsing error. No idea what it is or what the problem is. 2 Answers