Singularity/Library/PackageCache/com.unity.2d.pixel-perfect@.../Samples~/Scenes and Extras/Scenes/Scripts/BasicCameraFollow.cs

17 lines
508 B
C#
Raw Normal View History

2024-05-06 14:45:45 -04:00
using UnityEngine;
using System.Collections;
public class BasicCameraFollow : MonoBehaviour
{
public GameObject followTarget;
private Vector3 targetPos;
public float moveSpeed;
void Update ()
{
targetPos = new Vector3(followTarget.transform.position.x, followTarget.transform.position.y, transform.position.z);
Vector3 velocity = targetPos - transform.position;
transform.position = Vector3.SmoothDamp (transform.position, targetPos, ref velocity, 1.0f, moveSpeed * Time.deltaTime);
}
}