- Home /
Error CS8025: Parsing error. HELP!
I am new to all this, and I have begun a project for a game based around aircraft. To begin Im just starting with a basic code and for some reason whenever I begin playing it just says "error CS8025: Parsing error!"
This is the code;
}
var rotateSpeed = 25.0;
var speed = 50.0;
function Update() {
var transAmount = speed * Time.deltaTime;
var rotateAmount = rotateSpeed * Time.deltaTime;
if (Input.GetKey("up")) {
transform.Rotate(rotateAmount, 0, 0);
}
if (Input.GetKey("down")) {
transform.Rotate(-rotateAmount, 0, 0);
}
if (Input.GetKey("left")) {
transform.Rotate(0, -rotateAmount, 0);
}
if (Input.GetKey("right")) {
transform.Rotate(0, rotateAmount, 0);
}
if (Input.GetKey ("z")) {
transform.Rotate(0, 0, rotateAmount);
}
if (Input.GetKey ("x")) {
transform.Rotate(0, 0, -rotateAmount);
}
if (Input.GetKey ("a")) {
transform.Translate(0, 0, transAmount);
}
if (Input.GetKey ("q")) {
transform.Translate(0, 0, (transAmount * 2));
}
}
Any help would be greatly appreciated. Thanks!
Answer by perchik · Mar 19, 2014 at 05:24 PM
Your error message should refer to a specific line number which will tell you where the problem actually occurs (or within a line or two) and you should include that in your question.
With that said, if this is your complete code, you have a stray }
at the very beginning, which will cause problems.
This is all my code (I removed that bracket you were on about) "(4,18): error CS0116: A namespace can only contain types and namespace declarations"
using UnityEngine; using System.Collections;
public class NewBehaviourScript : $$anonymous$$onoBehaviour {
var rotateSpeed = 25.0;
var speed = 50.0;
function Update() {
var transAmount = speed * Time.deltaTime;
var rotateAmount = rotateSpeed * Time.deltaTime;
if (Input.Get$$anonymous$$ey("up")) {
transform.Rotate(rotateAmount, 0, 0);
}
if (Input.Get$$anonymous$$ey("down")) {
transform.Rotate(-rotateAmount, 0, 0);
}
if (Input.Get$$anonymous$$ey("left")) {
transform.Rotate(0, -rotateAmount, 0);
}
if (Input.Get$$anonymous$$ey("right")) {
transform.Rotate(0, rotateAmount, 0);
}
if (Input.Get$$anonymous$$ey ("z")) {
transform.Rotate(0, 0, rotateAmount);
}
if (Input.Get$$anonymous$$ey ("x")) {
transform.Rotate(0, 0, -rotateAmount);
}
if (Input.Get$$anonymous$$ey ("a")) {
transform.Translate(0, 0, transAmount);
}
if (Input.Get$$anonymous$$ey ("q")) {
transform.Translate(0, 0, (transAmount * 2));
}
}
It seems like you're writing C# in which case "function" is not the right syntax
ins$$anonymous$$d do
void Update(){
Yes, you have some C# and JavaScript stuff mixed together.
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : $$anonymous$$onoBehaviour {
float rotateSpeed = 25.0f;
float speed = 50.0f;
void Update() {
float transAmount = speed * Time.deltaTime;
float rotateAmount = rotateSpeed * Time.deltaTime;
if (Input.Get$$anonymous$$ey("up")) {
transform.Rotate(rotateAmount, 0, 0);
}
if (Input.Get$$anonymous$$ey("down")) {
transform.Rotate(-rotateAmount, 0, 0);
}
if (Input.Get$$anonymous$$ey("left")) {
transform.Rotate(0, -rotateAmount, 0);
}
if (Input.Get$$anonymous$$ey("right")) {
transform.Rotate(0, rotateAmount, 0);
}
if (Input.Get$$anonymous$$ey ("z")) {
transform.Rotate(0, 0, rotateAmount);
}
if (Input.Get$$anonymous$$ey ("x")) {
transform.Rotate(0, 0, -rotateAmount);
}
if (Input.Get$$anonymous$$ey ("a")) {
transform.Translate(0, 0, transAmount);
}
if (Input.Get$$anonymous$$ey ("q")) {
transform.Translate(0, 0, (transAmount * 2));
}
}
}
Ok, cheers for the help Dblfstr for the code, I am not recieving any "Cs8025" errors now, but NOW i am getting a new one;
"Actor::update$$anonymous$$assFromShapes: Compute mesh inertia tensor failed for one of the actor's mesh shapes! Please change mesh geometry or supply a tensor manually! UnityEditor.DockArea:OnGUI()"