Skip to content

Instantly share code, notes, and snippets.

@atlass-dev
Created March 11, 2021 13:31
Show Gist options
  • Save atlass-dev/9b95eb554f57b11d31a1acc8cc62ca51 to your computer and use it in GitHub Desktop.
Save atlass-dev/9b95eb554f57b11d31a1acc8cc62ca51 to your computer and use it in GitHub Desktop.
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