I am trying to make a maze game where the character moves along the x and y axis, but with the script that I have the character moves right thought the walls(which defeats the purpose of a maze game). How do I make my character move on the x and y axis without running though walls.
Here is the script that I am using:
function Start () {
}
function Update () {
if (Input.GetKeyDown(KeyCode.A)){
transform.Translate(Vector3.left * Time.deltaTime, Camera.main.transform);
}
if (Input.GetKeyDown(KeyCode.D)){
transform.Translate(Vector3.right * Time.deltaTime, Camera.main.transform);
}
if (Input.GetKeyDown(KeyCode.W)){
transform.Translate(Vector3.up * Time.deltaTime, Camera.main.transform);
}
if (Input.GetKeyDown(KeyCode.S)){
transform.Translate(Vector3.down * Time.deltaTime, Camera.main.transform);
}
}