Player with Collider Please Help me

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 :slight_smile:

You probably need to set up Layer-Based Collision.

Did you Select your Player and then go to… Component/Physics/RigidBody

and Component/Physics/BoxCollider

to assign them to your player ???