Camera system

Hello guys, i have make a system camera for following my game object (here a car), but i have a little problem, the camera follow all steps of the gameObjet, so when my car flip, the camera flip too, that annoying.
So, probably a stupid question but, how to make my camera follow player, lookt in the same direction of my car, but not rotate when the car flip ?

If you want to keep it as a child, then you have to reset the rotation with a script:

otherwise you can unparent and write a script so the camera translates to an offset of the position.

Personally I go for having a camera object as a child of an empty object, then I have a script on the empty object that follows a targets position & y rotation.

That what i did too, but now to get camera not go through wall, i am in trouble. I tried different thing, but no one do the trick very well.

Put objects that block the camera on their own collision layer. Do a raycast from the gameobject to the camera, if it hits anything bring it in, if you use a sphere cast you can pass in a radius so it gives time to blend.

Oh okay, thanks dude i was thinking about raycast, but i wasnt thinking like that !