I have a movement script. But when i press “W” and “D” ; its going one direction its pressed first. I want use both W and D same time. I need help. I couldnt fix. There is the code:
Rigidbody m_Rigidbody;
float m_Speed;
void Start()
{
m_Rigidbody = GetComponent<Rigidbody>();
m_Speed = 3.0f;
}
void Update () {
transform.LookAt (GameObject.Find("enemy").transform);
if (Input.GetKey(KeyCode.W))
{
m_Rigidbody.velocity = transform.forward * m_Speed;
}
if (Input.GetKey(KeyCode.S))
{
m_Rigidbody.velocity = -transform.forward * m_Speed;
}
if (Input.GetKey(KeyCode.A))
{
m_Rigidbody.velocity = -transform.right * m_Speed;
}
if (Input.GetKey(KeyCode.D))
{
m_Rigidbody.velocity = transform.right * m_Speed;
}
}