Created
March 11, 2021 13:31
-
-
Save atlass-dev/9b95eb554f57b11d31a1acc8cc62ca51 to your computer and use it in GitHub Desktop.
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 | |
{ | |
[SerializeField] private Transform player; | |
private Vector3 offset; | |
void Start() | |
{ | |
offset = transform.position - player.position; | |
} | |
void FixedUpdate() | |
{ | |
Vector3 newPosition = new Vector3(transform.position.x, transform.position.y, offset.z + player.position.z); | |
transform.position = newPosition; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment