using System.Collections; using System.Collections.Generic; using UnityEngine; public class CameraFollower : MonoBehaviour { public static CameraFollower instance; void Awake(){ instance = this; } public float Xsmoothness =1f; public float Ysmoothness =1f; public static Transform Target; public Vector2 offset; void FixedUpdate() { UpdateFrame(); } public static void UpdateFrame(){ instance.updateFrame(); } void updateFrame(){ float newX = Mathf.Lerp(transform.position.x, Target.position.x + offset.x, Xsmoothness); float newY = Mathf.Lerp(transform.position.y, Target.position.y + offset.y, Ysmoothness); transform.position = new Vector3(newX, newY, transform.position.z); } }