Beginner Programmer, Need some help

I am doing the 2D adventure game course and I’m having some issues with using Input Actions I try to implament it in my code and I’m just getting a bunch of errors and I’m not sure what I’m doing wrong.

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

public class PlayerController : MonoBehaviour
{
    

    public InputAction LeftAction;
    
    // Start is called before the first frame update
    void Start()
    {
        LeftAction.Enable();
    }

    // Update is called once per frame
    void Update()
    {
        float horizontal = 0.0f;
        float vertical = 0.0f;

        if (LeftAction.isPressed())
        {
            horizontal = -1.0f;
        }
        else if (Keyboard.current.rightArrowKey.isPressed)
        {
            horizontal = 1.0f;
        }

        if (Keyboard.current.upArrowKey.isPressed)
        {
            vertical = 1.0f;
        }
        else if (Keyboard.current.downArrowKey.isPressed)
        {
            vertical = -1.0f;
        }

        Debug.Log(horizontal);
        Debug.Log(vertical);

        Vector2 position = transform.position;
        position.x = position.x + 0.1f * horizontal;
        position.y = position.y + 0.1f * vertical;
        transform.position = position;
    }
}

Here is the code in it’s entirety I’m just not sure what I’m doing wrong as I’m trying to follow it to a T just to figure it out.

What are the actual errors? Are they compilation errors or runtime errors?

If possible post the full error message (in code tags).

NotImplementedException: The method or operation is not implemented.
PlayerController.Update () (at Assets/Scripts/PlayerController.cs:24)

This is what is said as I was testing in unity

I think you’ve missed capitalising the ‘i’ at the start of .isPressed(). All Unity’s method names start capitalised, ergo, .IsPressed().

If this isn’t a compilation error, then I guess there might be old deprecated methods in the InputAction API. Your code editor should be showing you when you’re using deprecated parts of an API.

1 Like

Thank you so much just needed someone else to say it I appreciate it.

1 Like

I’ll remove the 2D-physics tag because your question is nothing to do with it. In the future, if you have a scripting question, please use that tag instead.

Thanks.

1 Like