I have a Player(Cube). And left, right, up and down are walls(other cubes).
As soon as I touch the wall, I will not come on.
But I just go through through. And I do not want.
Here is the script.
function Update() {
//transform.Translate( 10, 0, 0);
if (Input.GetKey(KeyCode.A)){
transform.Translate( 0, 0, 10);
}
if (Input.GetKey(KeyCode.D)){
transform.Translate( 0, 0, -10);
}
if (Input.GetKey(KeyCode.W)){
transform.Translate( 0, 6, 0);
}
if (Input.GetKey(KeyCode.S)){
transform.Translate( 0, -6, 0);
}
}
Please help me, thanks ![]()