how to make player collide for swimming

i made my own simple script for moving and i added look script to the player to make a swimming like player. the problem is that it gos through everything terrain walls even with character controller and a collider so is there a way to stop the player from going through everything

I've asked this before, see if this will help you out: