Question by
shadowpuppet · May 17, 2016 at 02:02 AM ·
camera script
swap cameras with delay
I have spent days on trying this. several scripts here looked promising but bouncing back and forth between java and C# as well as making the slight changes I need to try to alter them for my needs is driving me crazy. Errors abound or they just don't work. All I want is that when the player walks into a trigger zone, 3 seconds pass by before the camera switches. I have the script for the switching I just can't successfully add the Ienumerator or coroutine to get a delay
using UnityEngine; using System.Collections;
public class cameraSwap : MonoBehaviour {
public Camera Camera1;
public Camera Camera2;
void Start () {
Camera1.enabled = true;
Camera2.enabled = false;
}
void OnTriggerEnter (Collider other) {
if(other.tag == "Player")
{
Camera1.enabled = false;
Camera2.enabled = true;
}
}
}
Comment
why didn't that paste correctly?
using UnityEngine; using System.Collections;
public class cameraSwap : $$anonymous$$onoBehaviour {
public Camera Camera1;
public Camera Camera2;
void Start () {
Camera1.enabled = true;
Camera2.enabled = false;
}
void OnTriggerEnter (Collider other) {
if(other.tag == "Player")
{
Camera1.enabled = false;
Camera2.enabled = true;
}
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612080949im_/https://answers.unity.com/themes/thub/images/avi.jpg)