Hi! Im making a game and I only want the player to be able to click “a” and “d” one and then not be able to move any more in that direction! Here is the movement code I have so far.
private float movementSpeed = 7f;
private float movementSpeed1 = -7f;
void Start()
{
}
void Update()
{
float horizontalInput = Input.GetAxis("Horizontal");
if (Input.GetKeyDown("d"))
{
transform.position = transform.position + new Vector3(movementSpeed * Time.deltaTime, horizontalInput * movementSpeed * Time.deltaTime, 0);
}
if (Input.GetKeyDown("a"))
{
transform.position = transform.position + new Vector3(movementSpeed1 * Time.deltaTime, horizontalInput * movementSpeed1 * Time.deltaTime, 0);
}
}