Skip to content

Instantly share code, notes, and snippets.

@oviniciusfaria
Last active October 21, 2023 12:16
Show Gist options
  • Save oviniciusfaria/c36965fbc30b5637a2c95a191186b6e5 to your computer and use it in GitHub Desktop.
Save oviniciusfaria/c36965fbc30b5637a2c95a191186b6e5 to your computer and use it in GitHub Desktop.
Smooth Camera Follow-Unity3D
using UnityEngine;
using System.Collections;
public class CameraController : MonoBehaviour
{
public GameObject Player;
public float suavidade = 2.0f;
void Update()
{
float interpolation = suavidade * Time.deltaTime;
Vector3 position = this.transform.position;
position.y = Mathf.Lerp(this.transform.position.y, Player.transform.position.y, interpolation);
position.x = Mathf.Lerp(this.transform.position.x, Player.transform.position.x, interpolation);
this.transform.position = position;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment