Hey guys.
I need a little help. I have a camera script that works perfectly only one thing. When I teleport the player down to another place in the same scene, I want that the camera works excatly same as above. How can I do this?
Here is a video what I mean:
https://www.youtube.com/watch?v=FnO441nnZXo
Camera script:
using UnityEngine;
using System.Collections;
public class MainCamera : MonoBehaviour {
public Transform target;
public int zOffset;
public int minimumHeight = 0;
float orthoSize;
float currentY;
Vector3 position;
// Use this for initialization
void Start () {
orthoSize = camera.orthographicSize;
}
// Update is called once per frame
void LateUpdate () {
position = target.position;
position.z -= zOffset;
currentY = target.position.y;
if (currentY > minimumHeight + orthoSize - 1)
{
position.y = currentY - orthoSize + 1;
}
else
{
position.y = minimumHeight;
}
transform.position = position;
}
}