- Home /
having problems converting this script to android
hi, i am working on an android racing game, the car script works fine but i have a camera script that swithces between first and third person views. i have one gui texture button that is supposed to switch cameras. the original script was to switch cameras on tab.
original:
var FirstPerson : Camera;
var ThirdPerson : Camera;
var Active : boolean = true;
function Start(){
FirstPerson.enabled = true;
ThirdPerson.enabled = false;
}
function Update(){
if(Input.GetButton("Tab") && Active == false)
{
FirstPerson.enabled = false;
ThirdPerson.enabled = true;
Active = true;
}
else if(Input.GetButton("Tab") && Active == true)
{
FirstPerson.enabled = true;
ThirdPerson.enabled = false;
Active = false;
}
}
what im working on:
var FirstPerson : Camera;
var ThirdPerson : Camera;
var camControl : GUITexture;
var Active : boolean = true;
function Start(){
FirstPerson.enabled = true;
ThirdPerson.enabled = false;
}
function Awake(){
camControl = GameObject.Find("Cameraicon").guiTexture;
}
function Update(){
if (Input.touchCount > 0) {
for (var touch : Touch in Input.touches) && Active == false
{
if (camControl.HitTest (touch.position)) ;
FirstPerson.enabled = false;
ThirdPerson.enabled = true;
//if(Input.GetButton("Tab") && Active == false)
//{
//FirstPerson.enabled = false;
// ThirdPerson.enabled = true;
Active = true;
}
}
else if (Input.touchCount > 0) {
for (var touch : Touch in Input.touches) && Active == true
{
if (camControl.HitTest (touch.position)) ;
FirstPerson.enabled = true;
ThirdPerson.enabled = false;
//else if(Input.GetButton("Tab") && Active == true)
//{
//FirstPerson.enabled = true;
//ThirdPerson.enabled = false;
Active = false;
}}
}
i get a lot of errors, please help
Answer by robertbu · Feb 11, 2013 at 04:42 AM
The "&& Active = true" is causing your compile errors. You are trying to mix a for() loop and a conditional that was originally part of an if() statement. Comment this statement out and your code will compile. You will have to figure out how to integrate the if() logic with your loop.
well, but how can i implement the active=true so i only need one gui texture, could you at least find a script like this that uses a gui texture, i cant seem to find one
I have no idea what this script is for. And am unlikely to know of another script related to camera viewpoint switching.