I have this script attached to my game object. Basically its a bridge that the player moves with A and D. I have another object that is the ground and when I move the bridge, it goes right through the ground. I know it does this because I am using transform.Rotate but anything else that I have tried dosent work. I know this is a simple question but I cant figure it out. Both of the objects have colliders and rigidbodies.
#pragma strict
var speed = 30;
function Update () {
if (Input.GetKey(KeyCode.A))
transform.Rotate(0, 0, speed, Space.World);
if (Input.GetKey(KeyCode.D))
transform.Rotate(0, 0, -speed, Space.World);
}