Hi all,
Is there a way to make my minimap camera move to the location of my active game camera if i have several cameras in the scene?
I only have one camera (apart from the minimap camera) active at any one time. I’m hoping there is some way I can make it flip between locations as I cycle through the cameras. This is the script that i currently have attached to the game object that holds all my cameras:
var selectedCamera : int = 0;
function Start ()
{
SelectCamera (0);
}
function Update ()
{
if (Input.GetKeyDown("x"))
{
selectedCamera++;
if(selectedCamera == transform.childCount){
selectedCamera = 0;
}
SelectCamera (selectedCamera);
}
if (Input.GetKeyDown("v"))
{
selectedCamera--;
if(selectedCamera < 0){
selectedCamera = transform.childCount;
}
SelectCamera (selectedCamera);
}
}
function SelectCamera (index : int)
{
for (var i=0;i<transform.childCount;i++)
{
if (i == index){
transform.GetChild(i).gameObject.SetActiveRecursively(true);
}
else{
transform.GetChild(i).gameObject.SetActiveRecursively(false);
}
}
}
Any help greatly appreciated.
Hi, Thanks for the reply, but i'm not really sure what you mean? I have all my cameras working as i want, and i have them all stored inside an empty game object so that they cycle through correctly. The activating and deactivating of the game cameras is working fine. The problem i am having is that i then have 1 minimap camera that is not linked to anything, and i'd like that camera to move to the position above where the active camera is so that my minimap position jumps from one location to another. Sorry if my earlier explanation was a little unclear.
– paulknight10