but when I turn near a wall it enter the wall and renders the scene from inside it
how will i stop it from enetring walls I wan it to be like Minecraft 3rd person camer
I have thought of making a raycast from the player with distance of the camera from the player and placing the camer where it collides but I dont want to waste my time trying
Yes, that’s how it’s normally done. But move your camera code into LateUpdate and not FixedUpdate. LateUpdate will be updated after Update and so if you move your player in Update then you can be sure the camera will always be updated immediately after the player has moved.
Also, by default FixedUpdate updates at 50hz and so your camera movement won’t be smooth on a display with a refresh rate higher than 50hz.
Normally, we’d use Cinemachine as spiney said because that has built-in collision avoidance with a quality that’s far superior than a single raycast (ie it won’t have the camera slide into a tiny crevice or hole in a wall … we often call them “windows”).