I got this invalid token error and I don't know how to fix it.

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

public class PlayerController : MonoBehaviour
{

    private Rigidbody rb;
    private movementX;
    private movementY;
    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody>();
    }
 
   void onMove(InputValue movementValue)
   {
   
     Vector2 movementVector = movementValue.Get<Vector2>();
     movementX = movementVector.x;
     movementY = movementVector.y; 
   }
 
   void FixedUpdate()
   {
     Vector3 movement = new Vector3(movementX, 0.0f, movementY);
     rb.AddForce(movement);
  
   }
}

Btw I just started learning Unity but I ran into this problem somehow even though I was following along a tutorial correctly

On line 10 and 11 you have not specified what type the variables are:

private movementX;
private movementY;

should probably be something like:

private float movementX;
private float movementY;
2 Likes

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

1 Like