In the previous Camera, you’d often lose sight of your player because something was obstructing your line of sight, such as a wall or a pillar. To prevent this from happening, we needed some kind of Collision Check on our Camera, to see whether or not the view was obstructed.
To achieve this, we simple have to cast a ray from our Camera’s Look at position to our Camera Position, and the first hit point of the Ray determines the new Camera position. This method is very simple and works for most cases, but it needs some tweaking and optimizing in a few occasions.
One of the main issues is that the Camera will “jump” to it’s new position. This sometimes gives ugly Camera movement and should be avoided.
Another issue is when you’re looking along the side of a wall. This will allow “wallhacks”, since the Camera will partly exactly on the face of the wall, meaning the first part of the wall will not be rendered due to it being outside the near plane. The backside of the wall is backfacing, making it is also ignored during rendertime.
We also weren’t sure whether to add the Terrain itself as a collider for the Camera. The pro of using it as a Collider is that you don’t see random gray-ish planes in your Viewport because of the raw terrain shape (some faces will not be entirely backfacing, so these will still be rendered). The con is however, is that your Camera will “jump” a lot while sliding across the faces of the terrain collider. This will give the Camera a “twitching” effect, which is not really what we want.
We’ve voted to ignore the Terrain Collider when casting the ray, as the con was more obtrusive than the pro.