Last active
October 21, 2023 12:16
-
-
Save oviniciusfaria/c36965fbc30b5637a2c95a191186b6e5 to your computer and use it in GitHub Desktop.
Smooth Camera Follow-Unity3D
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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