Sorry it’s my first time using Unity. If my question is too dumb or somewhere existed please easy on me.
I’m trying make some bomberman game on Unity. Camera will see it from top. And right now i’m only starting and trying make some movement. But on my current code, it’s moving directions i don’t want. For example, if you press W and D same time, it moving to top right corner. I still can’t decide what happen if player press W and D same time. It should go top or right? Also how I disable unwanted angle movements.
function Update () {
if(Input.GetKey("w")) {
transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);
}
if(Input.GetKey("s")){
transform.Translate(Vector3.back * moveSpeed * Time.deltaTime);
}
if(Input.GetKey("d")) {
transform.position += transform.right * moveSpeed * Time.deltaTime;
}
if(Input.GetKey("a")) {
transform.position -= transform.right * moveSpeed * Time.deltaTime;
}
}