# How do I do this!?

For example, if I hold ‘A’ I strafe left and if I hold ‘D’ I strafe left. But if I hold ‘A’ and ‘D’ at the same time… I start strafing in a random direction. I wan to implement that if I hold A’ and ‘D’ at the same time, my player will stop temporarily until I release one of the keys.

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

public class PlayerMovement : MonoBehaviour
{
public CharacterController controller;
public float speed = 12f;
public float gravity = -9.81f;
public float jumpHeight = 3f;
Vector3 velocity;

//ground stuff
public Transform groundCheck;
public float groundDistance = 0.4f;
bool isGrounded;

void Update()
{
//MOVE N' JUMP

if(isGrounded && velocity.y < 0)
{
velocity.y= -2f;
}

if(Input.GetButtonDown("Jump") && isGrounded)
{
velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
}
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");

Vector3 move = transform.right * x + transform.forward * z;

controller.Move(move * speed * Time.deltaTime);

velocity.y += gravity * Time.deltaTime;

controller.Move(velocity * Time.deltaTime);

}
}
``````

Maybe try:

``````if(Input.GetKey("d") && Input.GetKey("a")){
//Stop movement here
}
else{
//move forward
}
``````

Hope this helps!!