Created
November 8, 2021 13:10
-
-
Save onlyoneaman/4ba3d39b7527fdd4795fa474a8db2ce8 to your computer and use it in GitHub Desktop.
Camera Controller
This file contains 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 System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class CameraController : MonoBehaviour | |
{ | |
public GameObject player; | |
private Vector3 offset; | |
// Start is called before the first frame update | |
void Start() | |
{ | |
offset = transform.position - player.transform.position; | |
} | |
// Update is called once per frame | |
void LateUpdate() | |
{ | |
transform.position = player.transform.position + offset; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment