Last active
July 31, 2018 12:11
-
-
Save Arumksh/84b6a3a82107f3c990145b900ac602b5 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 { | |
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