Im trying to get the scene camera to jump to a prefab clone when it spawns in with a tag. The tag is camerafollowme. I just use the tag drop down bar in the inspector for tagging.
My overall goal is to have each client their own camera so it ignores cameras not local if anyone knows that one?
Also the comments in the text are me fooling around to try to get it to work. :?
//Transform target;
//public GameObject[] target;
public float dampTime = 0.15f;
private Vector3 velocity = Vector3.zero;
public Transform target;
void Start () {
//target = GameObject.FindGameObjectWithTag ("camerafollowme").transform;
}
// Update is called once per frame
void Update ()
{
if (target)
{
Vector3 point = GetComponent<Camera>().WorldToViewportPoint(target.position);
Vector3 delta = target.position - GetComponent<Camera>().ViewportToWorldPoint(new Vector3(0.5f, 0.5f, point.z)); //(new Vector3(0.5, 0.5, point.z));
Vector3 destination = transform.position + delta;
transform.position = Vector3.SmoothDamp(transform.position, destination, ref velocity, dampTime);
}
}
}