stickpoge/Assets/Scripts/CameraFollower.cs
2023-01-26 12:14:57 +05:30

31 lines
772 B
C#

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;
void Update()
{
UpdateFrame();
}
public static void UpdateFrame(){
instance.updateFrame();
}
void updateFrame(){
if(Target == null){return;}
float newX = Mathf.Lerp(transform.position.x, Target.position.x, Xsmoothness);
float newY = Mathf.Lerp(transform.position.y, Target.position.y, Ysmoothness);
transform.position = new Vector3(newX, newY, transform.position.z);
}
}