using UnityEngine; using UnityEngine.InputSystem; public class PlayerControl : MonoBehaviour { private CharacterController Figur; public float Speed = 5.0f; // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { Figur = GetComponent(); } // Update is called once per frame void Update() { // old Input handling - used in book /* if (Input.GetKey(KeyCode.LeftArrow)) Figur.Move(Vector3.left * Time.deltaTime * Speed); if (Input.GetKey(KeyCode.RightArrow)) Figur.Move(Vector3.right * Time.deltaTime * Speed); */ //new Input handling - arrows and wasd if (Keyboard.current.leftArrowKey.isPressed || Keyboard.current.aKey.isPressed) Figur.Move(Vector3.left * Time.deltaTime * Speed); if (Keyboard.current.rightArrowKey.isPressed || Keyboard.current.dKey.isPressed) Figur.Move(Vector3.right * Time.deltaTime * Speed); if (Keyboard.current.upArrowKey.isPressed || Keyboard.current.wKey.isPressed) Figur.Move(Vector3.up * Time.deltaTime * Speed); if (Keyboard.current.downArrowKey.isPressed || Keyboard.current.sKey.isPressed) Figur.Move(Vector3.down * Time.deltaTime * Speed); } }