I don't want my plane to go trough walls, I want it to stop on obstacles

I’m currently working on my first Unity Learn code challenge, making a Flappy Bird style game where a plane needs to fly through gaps between wall obstacles.

I’ve successfully implemented all the required features except for one: I want to add colliders to my obstacle prefabs, but I’m having trouble making them work. I’ve added colliders and a rigidbody, but the plane continues to fly right through the walls instead of stopping.

I utilized three scripts: PropellerSpin, PlayerController, and FollowPlayer for the camera.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PropollerSpin : MonoBehaviour
{
     public GameObject propeller;
     public float rotationSpeed = 10000f;

     // Update is called once per frame
    void Update()
    {
        transform.Rotate(rotationSpeed * Time.deltaTime * 
        Vector3.forward);
    }
 }
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;

public class PlayerControllerX : MonoBehaviour
{
     public float speed = 15.0f;
     public float rotationSpeed = 15.0f;
     public float verticalInput;
     //public float forwardInput;


     // Update is called once per frame
    void FixedUpdate()
    {
        // get the user's vertical input
        verticalInput = Input.GetAxis("Vertical");
        //forwardInput = Input.GetAxis("Vertical");
        


        // move the plane forward at a constant rate
        transform.Translate(speed * Time.deltaTime * Vector3.forward);

        // tilt the plane up/down based on up/down arrow keys
        transform.Rotate(rotationSpeed * Time.deltaTime * verticalInput * Vector3.right);
    }
 }
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FollowPlayerX : MonoBehaviour
{
     public GameObject plane;
     private Vector3 offset = new(30, 2,-1);

     // Update is called once per frame
    void LateUpdate()
    {
        transform.position = plane.transform.position + offset;
    }
}

Edit the Collider by pressing the button “Edit Collider” on the Box Collider Component and make sure its sized correctly. I see you changed the scale. I can’t remember if in 2D the collider scales automatically.

Also make sure the collider on the plane is not set to trigger.