I am trying to figure out how to make my camera follow a cloned prefab, but to no avail.
Is there something I should add to the code to help it find cloned objects?
using UnityEngine;
using System.Collections;
using ORKFramework;
public class CameraFollow : MonoBehaviour {
public Transform target;
public float m_speed = 0.1f;
Camera mycam;
// Use this for initialization
void Start ()
{
mycam =GetComponent ();
}
// Update is called once per frame
void Update () {
mycam.orthographicSize = (Screen.height / 2f) / 1f;
if (target) {
transform.position = Vector3.Lerp (transform.position, target.position, m_speed) + new Vector3 (0, 0, -10);
}
}
}
↧