Need help with this Script says that the name 'keyboard' does not exist in the current context

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

public class PlayerMove : MonoBehaviour
{

[SerializeField] private float movementSpeed = 5f;

private void Update() => move();

private void move()
{
Vector3 movement = new Vector3();

if (keyboard.current.wKey.isPressed) { movement.y += 1; }
if (keyboard.current.aKey.isPressed) { movement.x -= 1; }
if (keyboard.current.sKey.isPressed) { movement.y -= 1; }
if (keyboard.current.dKey.isPressed) { movement.x += 1; }

movement.Normalize();

transform.Translate(movement * movementSpeed * Time.deltaTime);
}

}

Same shit

  • make sure the new Input System is installed
  • learn that C# is case sensitive and make sure you’re writing Keyboard.current instead of keyboard.current.

It was installed and I reloaded the project. I vscode which runs with intellisense. It underlined even just “Keyboard” as an error.

1 Like

vs.

Which one then? Because the poster, whose post you hijacked was mistyping Keyboard. In the first post it is keyboard everywhere.

1 Like

Howdy. I had this problem and solved it by adding: (using UnityEngine.InputSystem; ) to the top of the script. Which the original poster also didn’t do. ^^
There is quite a bit of garbled info on this topic right now.
Maybe this will help someone.

3 Likes