How can I detect if the camera position is inside a mesh?

I’ve got a standard 3rd person perspective game, with the camera following behind the player character.

When I pan the camera around I’d like to know if it clips through another character in the world. In that case, I’d like to pull it out a bit further so you aren’t seeing the inside of a character’s mesh.

Does anyone have a good suggestion about how to go about doing this? Is there any kind of “is position inside mesh” function?

Thanks for any help!

Couldn’t you just use OnTriggerEnter/OnCollisionEnter and them move the camera slightly if a collision is detected.

Would be easy enough to attach a collider and rigidbody to the camera then just set gravity to off (or kinematic on)


Attach a collider to the camera and check if the collider on the camera is colling with the character or another collider in the scene and if it is then move the camera away.