This commit is contained in:
Gerard Gascón 2025-04-24 17:09:22 +02:00
commit 16da8e4dde
333 changed files with 109229 additions and 0 deletions

View file

@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraController : MonoBehaviour{
[HideInInspector]
public Transform follow;
public Vector2 minCamPos, maxCamPos;
public float smoothTime;
private Vector2 velocity;
// Update is called once per frame
void FixedUpdate(){
float posX = Mathf.SmoothDamp(transform.position.x,
follow.transform.position.x, ref velocity.x, smoothTime);
float posY = Mathf.SmoothDamp(transform.position.y,
follow.transform.position.y, ref velocity.y, smoothTime);
transform.position = new Vector3(
Mathf.Clamp(posX, minCamPos.x, maxCamPos.x),
Mathf.Clamp(posY, minCamPos.y, maxCamPos.y),
transform.position.z);
}
}