Object not colliding

I am a beginner and trying to recreate Pong.
I made this script for the movement but the object is clipping trough the walls i made.
This probably is because im just changing the transform.
Does anyone have a solution for this?
Script:

using UnityEngine;

public class Movement2 : MonoBehaviour
{

    public float movementForce = 0.2f;
 

    // Update is called once per frame
    void FixedUpdate()
    {
        if (Input.GetKey(KeyCode.W))
        {
           
                transform.position = transform.position + new Vector3(0, movementForce, 0);
           


        }

        if (Input.GetKey(KeyCode.S))
        {
             transform.position = transform.position + new Vector3(0, -movementForce, 0);
           

        }

    }
}

Why would it not though? I don’t see anything above that would stop it going through walls.

Unless you’re somehow expecting the physics system to do this? Presumably you’ve added a Rigidbody2D and some collider? If so then you’re directly setting the Transform position so the physics system can’t control the position. You are supposed to go through the Rigidbody2D API to effect changes and it updates the Transform position/rotation.

I would suggest you go through a basic 2D physics tutorial if that’s the case such as this one here.

Good luck.