2 Errors

Hey. I made a movement scripts and i have 2 errors:
Assets\Scripts\Movement.cs(12,30): error CS1002: ; expected
Assets\Scripts\Movement.cs(12,32): error CS1519: Invalid token ‘;’ in class, struct, or interface member declaration

Can someone help me?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Movement : MonoBehaviour
{

    public float speed;
    public float jump;

    private void move;
    private void Rigidbody2D rb;
    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        move = Input.GetAxis("Horizontal");

        rb.velocity = new Vector2(move * speed, rb.velocity.y);
        if (Input.GetButtonDown("jump"))
        {
            rb.AddForce(new Vector2(rb.velocity.x, jump));
        }
    }
}

void is not a type. It’s used for methods to declare that there is no return type.

So both void move; and void Rigidbody2D rb aren’t correct.

Remove the void from the Rigidbody2D rb and switch the void on the move to a float

2 Likes

How to understand compiler and other errors and even fix them yourself:

https://discussions.unity.com/t/824586/8

How to report your problem productively in the Unity3D forums:

http://plbm.com/?p=220

1 Like