Camera follow System (Unity, C#)

I developed this easily customizable camera follow system for a 3D platformer project. It featured hard and soft follow zones for the player, an independent virtual camera with its own follow parameters that controlled dead zones for height follow, and a radius and follow speed to the camera rig.



The system makes use of Unity's Cinemachine package for a simple 'look at target' behaviours that included dead, soft and hard zones.
It is fully customizable, as parameters are made visible to the Editor using Serialize Fields and other Unity editor tags.


Code Snippet:

void cameraCillinderFollow()
{
      // Calculate Point of Intersection between camera and camera roaming circle.
      Vector2 deltaPOI = mathsUtil.findCirclePOI(transform.position, followTarget.position, cameraCillinderRadius);

      // Clamp camera height
      float deltaHeight = Mathf.Clamp(theCamera.position.y,                                 
                                      transform.position.y + cameraCillinderBottomHeight,
                                      transform.position.y + cameraCillinderTopHeight);

      // Calculculate POI relative to camera and with clamped height
      Vector3 cameraCirclePOI = new Vector3(deltaPOI.x + transform.position.x, 
                                            deltaHeight,
                                            deltaPOI.y + transform.position.z);

     // Impose delta movement to camera
     theCamera.position = Vector3.Lerp(theCamera.position, cameraCirclePOI, Time.deltaTime * cameraFollowSpeed);
}';