This person has their camera follow their player but also slightly in the direction of their mouse and I think it looks really smooth but I haven't been able to make it. I'm using cinemachine.
If you're asking if cinemachine has this built-in, I don't think so. There's probably a more proper way to create that behavior by making a new cinemachine extension subclass, but I still haven't gotten around to learning cinemachine's workflow for that. So my suggestion is to create a different follow target which is coded to always be at some position between the player and the mouse, based on the distance between them. Cinemachine should take care of following it with damped movement, etc.
You'd want to use Clamping for the camera. I have two videos to make today, and the third video will be this method of camera smooth follow. The script is designed, all I gotta do is get the videos up. My PC has been recording at 17 fps instead of 30fps causing lag issues. I'm working on getting this sorted out. However, I will be back here when I publish the video so you can see how this works. Best part, the code I provide will work for side scrolling or top down as demonstrated in this video. There's only 73 lines of code (But I made comments you won't need so less than 70 actually.
Here's the video I promised, had to cut the end due to severe lag. My computer sux, I guess :/ Here's the script that makes it happen! Enjoy! Code (CSharp): using UnityEngine; public class CameraFollow : MonoBehaviour { [Header("Player's Transform")] [SerializeField] private Transform player; [Header("Camera Offset Field")] [SerializeField] private bool maxXenabled = false; [SerializeField] private float maxXset = 0f; [SerializeField] private bool minXenabled = false; [SerializeField] private float minXset = 0f; [SerializeField] private bool maxYenabled = false; [SerializeField] private float maxYset = 0f; [SerializeField] private bool minYenabled = false; [SerializeField] private float minYset; // Non inspector field object variables private Vector3 camPos; private Vector3 camVel = Vector3.zero; // Vector3(0,0,0); private float camLagTimer = 0.25f; private void FixedUpdate() { camPos = player.position; camPos.z = transform.position.z; // Horizontal clamping controls if(minXenabled == true && maxXenabled == true) { camPos.x = Mathf.Clamp(player.position.x, minXset, maxXset); } else if(minXenabled == true) { camPos.x = Mathf.Clamp(player.position.x, minXset, player.position.x); } else if(maxXenabled == true) { camPos.x = Mathf.Clamp(player.position.x, player.position.x, maxXset); } // Verticle clamping controls if (minYenabled == true && maxYenabled == true) { camPos.y = Mathf.Clamp(player.position.y, minYset, maxYset); } else if (minYenabled == true) { camPos.y = Mathf.Clamp(player.position.y, minYset, player.position.y); } else if (maxYenabled == true) { camPos.y = Mathf.Clamp(player.position.y, player.position.y, maxYset); } // Update the camera position transform.position = Vector3.SmoothDamp(transform.position, camPos, ref camVel, camLagTimer); } }