- Home /
Trouble getting the second touch to register, please help
I am trying to work on a game and the basic gist of what I am trying to accomplish at this time is to click on one cube, it switches to the second camera, once everything is finished there, the first camera is back active. Then the second cube is tapped and it takes me off again to another camera. However this is where the problem happens, I am able to tap the first box and go off to another camera perspective, complete what I have to then return but, when the second cube appears and I tap on it, the game pauses for perhaps a second or 2 then does nothing. Can someone please help I have been stuck for 2 days =(.
Below is the code that I have got in the game. Thank you.
var mainStage : GameObject;
var stage1 : GameObject;
var stage2 : GameObject;
var inputCamera : Camera;
private var hit : RaycastHit;
private var ray : Ray;
private var buttonPressed : boolean = false;
function Start () { mainStage.active = true; stage1.active = false; }
function walkingForward() { if(mainStage.active == true) { transform.Translate(-0.06,0,0); }
if(mainStage.active == false)
{
transform.Translate(0.00,0,0);
}
}
function FixedUpdate () { if (Input.touchCount == 1) { var touch : Touch = Input.touches[0];
if(touch.phase == TouchPhase.Began)
{
ray = inputCamera.ScreenPointToRay(touch.position);
if(Physics.Raycast(ray, hit))
{
switch(hit.collider.name)
{
case "Player Warning 1":
if(!buttonPressed)
{
mainStage.active = false;
stage1.active = true;
}
break;
case "Player Warning 2":
if(!buttonPressed)
{
mainStage.active = false;
stage2.active = true;
}
break;
}
}
}
}
}
function Update () { walkingForward(); }
Your answer
![](https://koobas.hobune.stream/wayback/20220613092328im_/https://answers.unity.com/themes/thub/images/avi.jpg)