Search Unity

Errors in 2D code "Motor Game" in Csharp

Discussion in 'Scripting' started by Black Daylight studios, Feb 27, 2015.

  1. Black Daylight studios

    Black Daylight studios

    Joined:
    Feb 27, 2015
    Posts:
    11
    Hey there,
    I have started working on a 2D Racing Game with motors. Now i started on the script for the moving of the motorcycle and came across a few errors that i cant seem to get fixed. Bare in mind, Im a beginner so all positive answers are welcome.

    The errors i get:
    CS1519: Unexpected symbol 'void' in class,struct or interface member declaration.
    CS1525: Unexpected symbol 'CharacterController'.

    This is the code:
    using UnityEngine;
    using System.Collections;


    [RequireComponent (typeof(CharacterController))]
    public class FirstPersonController : MonoBehaviour {

    public float MovementSpeed = 4.0f;
    public float RotationSpeed = 2.5f;

    float VerticalVelocity = 0f;

    CharacterController CharacterController

    // Use this for initialization
    void Start () {
    Screen.lockCursor = true;
    CharacterController = GetComponent<CharacterController>();
    }

    // Update is called once per frame
    void Update () {
    // Rotation

    float rotUpDown = Input.GetAxis("Mouse Y") * RotationSpeed;
    transform.Rotate (0, rotUpDown, 0) ;

    //movement

    float ForwardSpeed = Input.GetAxis ("Horizontal") * MovementSpeed;
    float BackwardsSpeed = Input.GetAxis ("Horizontal") * MovementSpeed * -0.5;

    VerticalVelocity += Physics.gravity.y * Time.deltaTime;

    Vector3 speed = new Vector3 (MovementSpeed, VerticalVelocity, 0)

    CharacterController.Move (speed * Time.deltaTime);

    }
    }
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,445