Roll-A-Ball Script Error

help wantedHi, I’m new to Unity and I’m trying to make the minigame of Roll-a-Ball.
I’m facing problem even I had followed the tutorial, enter the code to the Visual Studio.

The code

using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerController : MonoBehaviour
{
    private Rigidbody rb;
    private float movementX;
    private float movementY;

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

    void OnMove(InputValue movementValue) {
        Vector2 movementVector = movementVector.Get<Vector2>();

        movementX = movementVector.x;
        movementY = movementVector.y;
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        Vector3 movement = new Vector3(movementX, 0.0f, movementY);

        rb.AddForce(movement);
    }
}

When going to compile, it shows this:

I can’t figure out what’s wrong it is behind the code.
Hope I can be get help by somebody ; )

Vector2 movementVector = movementVector.Get<Vector2>();

Should be

Vector2 movementVector = movementValue.Get<Vector2>();

Because you are basically writing:

Vector2 movementVector;
movementVector = movementVector .Get<Vector2>();

And Vector2 doesn’t have a .Get<Vector2>() Method

Are you using Visual Studio? Because when I copied and pasted the code, it lit up immediately, hovering over it revealed the issue.

Got it! Thanks! : )
Sorry… I’m a newbie… just notice that… thankss!!

1 Like