Skip to content

Instantly share code, notes, and snippets.

@Arumksh
Last active July 31, 2018 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arumksh/84b6a3a82107f3c990145b900ac602b5 to your computer and use it in GitHub Desktop.
Save Arumksh/84b6a3a82107f3c990145b900ac602b5 to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraController : MonoBehaviour {
public float offsetX;
public float offsetY;
public Transform targetTrans;
void Start () {
if (targetTrans == null)
{
targetTrans = GameObject.FindGameObjectWithTag("Player").GetComponent<Transform>();
if(targetTrans == null)
{
return;
}
}
}
void LateUpdate()
{
this.transform.position = new Vector3
(playerTrans.position.x + offsetX,
playerTrans.position.y + offsetY,
-10);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment