How to make my gabeobject collide?

So im using this code to move around an object, but i dont know how to make it collide with the walls. No matter what I do the gameobject just goes through the walls or if it hits them they bounce. Sorry if its too simple I am new.

using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;
    
    public class controller : MonoBehaviour {
    	private float dist;
    	private bool dragging = false;
    	private Vector3 offset;
    	private Transform toDrag;
    	public Text score;
    	public int counterofbeers;
    	public Touch touch;
    	public bool lampa=false;
    	void Awake(){
    		counterofbeers = 0;
    	}
    	void Update() {
    		score.text= counterofbeers.ToString ();
    		Vector3 v3;
    
    		if (Input.touchCount != 1) {
    			dragging = false; 
    			return;
    		}
    
    		touch = Input.touches[0];
    		Vector3 pos = touch.position;
    
    		if(touch.phase == TouchPhase.Began) {
    			RaycastHit hit;
    			Ray ray = Camera.main.ScreenPointToRay(pos); 
    			if(Physics.Raycast(ray, out hit) && (hit.collider.tag == "Draggable"))
    			{
    				Debug.Log ("Here");
    				toDrag = hit.transform;
    				dist = hit.transform.position.z - Camera.main.transform.position.z;
    				v3 = new Vector3(pos.x,dist);
    				v3 = Camera.main.ScreenToWorldPoint(v3);
    				offset = toDrag.position - v3;
    				dragging = true;
    			}
    		}
    		if (dragging && touch.phase == TouchPhase.Moved) {
    			v3 = new Vector3(Input.mousePosition.x,dist);
    			v3 = Camera.main.ScreenToWorldPoint(v3);
    			toDrag.position = v3 + offset;
    		}
    		if (dragging && (touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled)) {
    			dragging = false;
    		}
    
    	}
    	void OnTriggerEnter(Collider other)	{
    		if (other.gameObject.CompareTag ("pickup")) {
    			Destroy (other.gameObject);	counterofbeers++;
    		}
    		if(other.gameObject.CompareTag("wall")){
    			lampa=true;
    		}
    	}
    }

does the object have a rigidbody and a collider? What bounces the wall or the object?