i have changed a camera script.
var Object1 : GameObject;
var Object2 : GameObject;
private var startObject : int = 1;
function Start ()
{
Object1.enabled = true;
Object2.enabled = false;
startObject = 1;
}
function Update ()
{
if(Input.GetKeyDown(“f”) (startObject == 1))
{
startObject = 2;
Object1.enabled = false;
Object2.enabled = true;
}
else if (Input.GetKeyDown(“c”) (startObject == 2))
{
startObject = 1;
Object1.enabled = true;
Object2.enabled = false;
}
}
why is this not working
1, you are using enabled on a GameObject. this does not work.
Your code simplified:
var Objects : GameObject[];
private var current : int = 1;
function Start ()
{
Object[0].active = true;
Object[1].active = false;
current = 0;
}
function Update ()
{
if(Input.GetKeyDown("f")){
for(var Obj:GameObject in Objects) Obj.active = false;
current = 1-current;
Objects[current].active = true;
}
}
bigmisterb:
1, you are using enabled on a GameObject. this does not work.
Your code simplified:
var Objects : GameObject[];
private var current : int = 1;
function Start ()
{
Object[0].active = true;
Object[1].active = false;
current = 0;
}
function Update ()
{
if(Input.GetKeyDown("f")){
for(var Obj:GameObject in Objects) Obj.active = false;
current = 1-current;
Objects[current].active = true;
}
}
is there a way to detect which camera is active?
i also want it to switch is this ok?
var Objects : GameObject[ ];
private var current : int = 1;
function Start ()
{
Object[0].active = true;
Object[1].active = false;
current = 0;
}
function Update ()
{
if(Input.GetKeyDown(“f”)){
for(var Obj:GameObject in Objects) Obj.active = false;
current = 1-current;
Objects[current].active = true;
}else{
Input.GetKeyDown(“c”)
for(var Obj:GameObject in Objects) Obj.active = true;
current = 1-current;
Objects[current].active = false;
}
}