Skip to content

Instantly share code, notes, and snippets.

@jacks205
Created December 4, 2014 23:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacks205/5732ba231d349a25448a to your computer and use it in GitHub Desktop.
Save jacks205/5732ba231d349a25448a to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class MenuCamera : MonoBehaviour {
public Transform[] cameraPositions;
public Vector2[] moveSpeeds;
public float[] cameraZoomSpeeds;
public float[] initalZoom;
public float timeAtEachPosition = 5f;
float timer = 0;
int index = 0;
int length;
Camera camera;
// Use this for initialization
void Start () {
length = cameraPositions.Length;
camera = GetComponent<Camera>();
}
// Update is called once per frame
void Update () {
timer += Time.deltaTime;
if (timer >= timeAtEachPosition)
{
if(index == length - 1)
index = -1;
++index;
Vector3 newPosition = new Vector3(cameraPositions [index].position.x, cameraPositions [index].position.y, -10);
transform.position = newPosition;
camera.orthographicSize = initalZoom[index];
timer = 0;
}
transform.Translate(moveSpeeds[index]);
camera.orthographicSize += cameraZoomSpeeds [index];
// Debug.Log(camera.orthographicSize);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment