Last active
August 29, 2015 14:26
-
-
Save seamanmur/7d2878cbc1b09478a6e5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 UnityEngine; | |
class CharTPSCamera : MonoBehaviour | |
{ | |
public static CharTPSCamera instance; | |
public Transform target; | |
void Awake() | |
{ | |
instance = this; | |
} | |
void Start() | |
{ | |
} | |
static public void GetCamera() | |
{ | |
GameObject tempCamera; | |
GameObject targetTemp; | |
CharTPSCamera myCamera; | |
if (Camera.mainCamera != null) tempCamera = Camera.mainCamera.gameObject; | |
else | |
{ | |
tempCamera = new GameObject("Main Camera"); | |
tempCamera.AddComponent("Camera"); | |
tempCamera.tag = "Main Camera"; | |
}; | |
tempCamera.AddComponent("CharTPSCamera"); | |
myCamera = tempCamera.GetComponent<CharTPSCamera>(); | |
targetTemp = GameObject.Find("targetLookAt"); | |
if (targetTemp == null) | |
{ | |
targetTemp = new GameObject("targetLookAt"); | |
targetTemp.transform.position = Vector3.zero; | |
} | |
myCamera.target = targetTemp.transform; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment