- Home /
Duplicate Question
Parsing Error at End of Script?
using UnityEngine;
using System.Collections;
public class FirstPersonController : MonoBehaviour {
public float MovementSpeed = 5.0f;
public float MouseSensitivity = 5.0f;
public float UpDownRange = 60.0f;
public float jumpSpeed = 20.0f;
float verticalVelocity = 0;
// Use this for initialization
void Start () {
Screen.lockCursor = true;
}
// Update is called once per frame
void Update () {
CharacterController cc = GetComponent<CharacterController> ();
//Rotation
float rotLeftRight = Input.GetAxis ("Mouse X") * MouseSensitivity;
transform.Rotate (0, rotLeftRight, 0);
float rotUpDown = Input.GetAxis ("Mouse Y") * MouseSensitivity;
float currentUpDown = Camera.main.transform.rotation.eulerAngles.x;
float desiredUpDown = currentUpDown - rotUpDown;
//desiredUpDown = Mathf.Clamp(desiredUpDown, -UpDownRange, UpDownRange);
Camera.main.transform.localRotation = Quaternion.Euler (desiredUpDown, 0, 0);
//Movement
float forwardspeed = Input.GetAxis ("Vertical") * MovementSpeed;
float sidespeed = Input.GetAxis ("Horizontal") * MovementSpeed;
verticalVelocity += Physics.gravity.y * Time.deltaTime;
if (Input.GetButton("Jump") ) {
verticalVelocity = jumpSpeed;
{
Vector3 speed = new Vector3 (sidespeed, verticalVelocity, forwardspeed);
speed = transform.rotation * speed;
cc.Move( Speed * Time.deltaTime );
So, I have a problem. A parsing error occurs at the end of my script, and no matter how I manipulate and changes the position of things, it is always on the last line of code. What is happening, and what is the solution?
For future questions, search UA for your error before posting a question. This particular error is almost always a bracketing problem...usually a missing bracket at the end of the file. I see missing brackets, and a wrong bracket. Go through your code and get matching closing brackets for every open bracket.
could you possibly point them out..? I am a noob here and don't see them. D:
Your Update() function has no closing bracket, your class is not closed, and I'm guessing that the bracket on line 45 is the wrong way. There may be other issues. In $$anonymous$$onodevelop, if you place your cursor on one bracket, the matching (if any) bracket is highlighted. Go through your code and figure out all the bracket pairs.
@theorbitgames, if you are who I think you are, then you should know the reasons why we push back on questions. There are consequences to just allowing all questions on the list. The mission of Unity Answers is to provide a repository of answers so that other can search out solutions. In the past year the list has been so overwhelmed by beginner questions and so many duplicate questions that a good portion of the heavyweight contributors (the ones that help solve the difficult problems or have concrete insight into Unity) have fled regular participation on this site. This means when you really get stuck with an issue beyond beginning Unity coding, they will not be there to help you. In addition, these duplicate questions have so buried the older, informed and detailed answers, that it is beco$$anonymous$$g harder to find answers on UA.
As for this specific question, 1) it added no value to UA since it has been answer so many times, 2) it is not a Unity question since this C# script would generate the same error no matter what C# compiler or environment was used, and 3) I did OP no favors by finally giving him the debugged code. That is, the fundamental issue is that he does not understand the structure of a C# class (nor do I believe he understands the code itself). In the long run he would have been far better off fighting through the issue until he understood the structure of C# and solving it himself, rather than have me give him the solution.
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
I need help with this script, where are the errors? 2 Answers
Enter Trigger, display Text, then delete object 1 Answer
C# damage script help 1 Answer
Spawn Script Issue 0 Answers