- Home /
Problem with Touch Screen Raycast or Array
Hi! I've a problem. I'm making a sort of Rubik's Cube game, but I have a problem for the rotation of the group of box. I think that the problem is in the definition of the array like a GameObject. You can help me? Thanks!
#pragma strict
var cubi:GameObject[];
var cubo:GameObject;
function Start () {
}
function Update () {
if (Input.touchCount > 0)
{
var raycast = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
var hit : RaycastHit;
if(Physics.Raycast(raycast, hit)){
if(Input.GetTouch(0).phase == TouchPhase.Began){
var touchpos = Input.GetTouch(0).deltaPosition.x;
for (var i=0; i < cubi.length; i++)
{
cubo = cubi[i];
cubo.transform.RotateAround(Vector3.up, 90);
}
}
}
}
}
You might get more help if you explained what it should be doing and what problems you are having. A video or drawing can be helpful for this kind of problem. I see issues (like why do the Raycast() if the 'phase' is not 'TouchPhase.Began'), but nothing that would count as 'problem for the rotation'.
Your answer
Follow this Question
Related Questions
Raycast cycle problem? 0 Answers
script is not working Using raycast show PopUp on click 0 Answers
Problem with World Generate 1 Answer
How can I order an array of RaycastHits in reverse order of distance? 1 Answer
I am making android fps and my raycast shooting button don't work. What I should do? 1 Answer