Colliders not working

im currently working my way through the recently released “Classic Game Design” and for some reason the colliders just aren’t working. This is the 2nd game in the book and they didn’t work for the first one either (which was pong). The paddle just ends up clipping through the boundaries when you move it towards them. All of the objects have a box collider so i have no idea what could be causing this and whether or not this was an intentional decision from the author.

screen:

alt text

Updated answer :slight_smile:

public class PlayerScript : MonoBehaviour 
{


    void Start () 
    {
       Screen.lockCursor = true;
    }


    void Update () 
    {
       if(Input.GetKey("left"))
       {
         transform.Translate(-20 * Time.deltaTime, 0, 0);
       }

       if(Input.GetKey("right"))
       {
         transform.Translate(20 * Time.deltaTime, 0, 0);
       }

       float h = 30.0f * Time.deltaTime * Input.GetAxis ("Mouse X");
       transform.Translate (h, 0, 0);
       transform.position = new Vector3(Mathf.Clamp(transform.position.x, -5f, 5f), transform.position.y, transform.position.z);

    }

    void OnTriggerEnter (Collider other)
    {
       BallScript.yspeed = -BallScript.yspeed;

       if(other.collider.gameObject.transform.position.x > gameObject.transform.position.x)
       {
         BallScript.xspeed = Mathf.Abs(BallScript.xspeed);
       }

       else
       {
         BallScript.xspeed = - Mathf.Abs(BallScript.xspeed);
       }

       BallScript.collflag = true;

    }

}