void requires a ; ?

Hello,

I am working on the player for a VR game I am working on. I am pretty sure my code is correct, but I keep receiving an error saying that my “void Start() {}” and “void Update() {}” is expecting a “;” and that “void” itself is an unexpected symbol. I don’t know why it is doing this. If you look at the script, everything was fine until I added my jump direction vector 3 and separated the move and jump sections. (I am using 5.5.0 since I was following the NUrFace tutorial on YouTube)

-Jeff

using UnityEngine;
using System.Collections;
using XInputDotNetPure;

[RequireComponent(typeof(CharacterController))]
public class PlayerMovement : MonoBehaviour
{
    CharacterController myCC;
    public float speed = 2f;
    public float jumpSpeed = 10f;
    public float duckSpeed = -2f;
    //public float MaxJump = 2.5f;
    public float gravity = 20f;
    private Vector3 moveDirection = Vector3.zero;
    private Vector3 HomePos = Vector3.zero;
    private Vector3 CurrentPos;
    private Vector3 MovePos;
    private Vector3 jumpDirection = Vector3.zero

    // Use this for initialization
    void Start()
    {
        myCC = gameObject.GetComponent<CharacterController>();
    }

    // Update is called once per frame
    void Update()
    {
//Move
        moveDirection = new Vector3(Input.GetAxis("XboxLx"), 0, Input.GetAxis("XboxLy"));
        moveDirection = transform.TransformDirection(moveDirection);
        moveDirection *= speed;
        myCC.Move(moveDirection * Time.deltaTime);

//Jump
        if (myCC.isGrounded)
        {
            //            moveDirection = new Vector3(Input.GetAxis("XboxLx"), 0, Input.GetAxis("XboxLy"));
            jumpDirection = new Vector3(0, 0, 0);
            jumpDirection = transform.TransformDirection(jumpDirection);
            jumpDirection *= speed;
            if (Input.GetButton("AButton"))
                jumpDirection.y = jumpSpeed;
        }
        jumpDirection.y -= gravity * Time.deltaTime;
        myCC.Move(jumpDirection * Time.deltaTime);

//Reset Position
        if (Input.GetButtonDown("XButton") == true)
        {
            //Defines "MovePos" to the transform inputs
            Vector3 MovePos = myCC.transform.position = HomePos;
            //Moves "myCC"
            myCC.transform.Translate(MovePos);
            //Resets Rotation
            myCC.transform.rotation = Quaternion.identity;
        }
    }
}

3028386--226400--void error.png
3028386--226401--expected.png
3028386–226402–PlayerMovement.cs (1.92 KB)

Line 18 is missing a semicolon.

1 Like

herp-derp. I feel like an idiot. thank you for that.

Missing or unexpected symbol is frequently to do with the line before the error, not the line the error is on.

3 Likes