Hey everyone!
I want my players to move with arrow keys instead of WASD because I intend for there to be an always active text input field, and WASD movement would result in unwanted text.
In my current build, both WASD and arrow keys work, but WASD is undesireable.
My top down, 2D player movement uses the following script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerCtrl : MonoBehaviour
{
public float movSpeed;
float speedX, speedY;
Rigidbody2D rb;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
speedX = Input.GetAxisRaw("Horizontal") * movSpeed;
speedY = Input.GetAxisRaw("Vertical") * movSpeed;
rb.linearVelocity = new Vector2(speedX, speedY);
}
}
Plus a Rigid 2D component and a Box Collider
How can I deactive WASD movement and keep only arrow keys?