Camera Collisions

  1. I have a robust camera script that can be tweaked to specific angles like it can be used for isometric view, 3rd person, 1st person and over the shoulder view.
  2. The problem is when using it as a 3rd person or over the shoulder camera it goes through the walls as it is following the player.
  3. So i need the most efficient solution. Should i add a collider and a collision script to reset the camera to a reset position when it collides with other environment or enemy game objects(like enemy coming from behind) or can anyone suggest a more efficient solution based on APIs i dont know about or by using relational vectors.

4.IS , NAVMESHAGENT A SOLUTION? plz try to confirm as the camera will not only move from one point to another but will do so avoiding the walls.And on a scripting perspective the code will be more robust.

Physics.Linecast/raycast back from the player’s head/shoulder to the max distance the camera should be.

If it hits something, then just move the camera forward to that point, with some added offset so it’s not flush with the surface.