First of all... I am not a native English speaker, so sorry for the bad English skills, I am doing my best to improve them.
so, I was working on this simple Character movement system and when I was testing I realized that if a press down "W"or "S" keys the player will move forward,and if I press "A" or "D" the player will move backwards and not sideways, and I have been searching and searching and I couldn't find anything similar to my problem... can someone help me?
void Update () {
// input
Vector2 input = new Vector2 (Input.GetAxisRaw ("Horizontal"), Input.GetAxisRaw ("Vertical"));
Vector2 inputDir = input.normalized;
bool running = Input.GetKey (KeyCode.LeftShift);
Move (input, running);
if (Input.GetKeyDown (KeyCode.Space)) {
Jump ();
}
}
void Move(Vector2 inputDir, bool running) {
float targetSpeed = ((running) ? runSpeed : walkSpeed);
float realSpeed = targetSpeed * Time.deltaTime;
Vector3 directionToMove = new Vector3 (inputDir.x, 0, inputDir.y) * realSpeed;
transform.Translate (directionToMove);
}
