Expected } In unity 3D Game

Ahmadfarooq710 1 Reputation point
2022-03-27T13:24:22.823+00:00

Hi all, Ive recently been making a first person shooter game on unity and I got to the point where I was programming the jump option for the player. I wrote the code but I got one error and I cant seem to figure it out, Please help.

Code:
void ApplyGravity() {

        if (character_Controller.isGrounded)
        {
            vertical_Velocity -= gravity * Time.deltaTime;

            //jump
            PlayerJump();

        } else {
            vertical_Velocity -= gravity * Time.deltaTime;


            // move_Direction.y = vertical_Velocity * Time.deltaTime;
            move_Direction.y = vertical_Velocity; 
        void PlayerJump() { }

        } // apply gravity

        void PlayerJump() {
            if (character_Controller.isGrounded && Input.GetKeyDown(KeyCode.Space)) {
                vertical_Velocity = jumpForce;
            }
        }


           

}

// class

Error: Assets/MoveScript.cs(71,2): error CS1513: } expected

If you all want then I can post the screenshot of my Visual Studio code as well, but please help.

Microsoft Authenticator
Microsoft Authenticator
A Microsoft app for iOS and Android devices that enables authentication with two-factor verification, phone sign-in, and code generation.
5,802 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Alison 1 Reputation point
    2022-06-26T11:33:01.117+00:00

    I think the problem lies in line 14, where u should just write void PlayerJump() without the curly bracket instead.

    0 comments No comments