Hi. I’m trying to create a cool camera panning overview of a level before you start playing it.
I have two scripts on my camera:
CameraManager
, which controls the camera while you’re playing the level, andCameraPan
, which runs at the start of the level, disablingCameraManager
until it’s done, then it deletes itself.CameraPan
just teleports through all the waypoints so fast it’s finished before I even see it.
CameraPan.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraPan : MonoBehaviour
{
public Vector3[] waypointPos;
public Vector3[] waypointDir;
public float[] waypointSpeed;
// Start is called before the first frame update
void Start()
{
GetComponent<CameraManager>().enabled = false;
}
// Update is called once per frame
void Update()
{
if (GameObject.Find("Music").GetComponent<Music>().isHub == false)
{
transform.position = waypointPos[0];
transform.eulerAngles = waypointDir[0];
for (int i = 1; i > waypointDir.Length; i++)
{
transform.position = Vector3.MoveTowards(transform.position, waypointPos[i], waypointSpeed[i] * Time.deltaTime);
transform.eulerAngles = Vector3.RotateTowards(transform.eulerAngles, waypointDir[i], waypointSpeed[i] * Time.deltaTime, 0);
}
}
GetComponent<CameraManager>().enabled = true;
Destroy(this);
}
}