Hii, i am trying to create one memory game. In which i can click on number of prefabs(cubes) which are present
there.Now i want to apply condition that, unless i'll click on certain number of cubes, i cant go to next scene.
Eg: If we r having 3 cubes present on scene, and i need to click on 'two' correct one cubes.Now here
how can i check that they are clicked on correct one?
we can move to further scene if and if only when we confirmed that one has correctly clicked on two correct cubes.
If my question seems incomplete, then also let me know , i'll try to explore it.
well if you are asking for some especific prefabs, then you need to have 3 or n number of booleans, then in the update, on a foreach touch, make a raycast to the touch.position, then check if the raycast hit one of your designated prefabs, if so, turn a bool on, continue this proces for your n prefabs/touches, and if all your booleans are on, then make an Application.Load(scene)
hope this is the answer you are looking for
ok, i am trying on this way.. private var hit : RaycastHit; private var isTouchCube1:boolean=false; private var isTouchCube2:boolean=false; function Update () { if((hit.box_v001_2==clicked)&&(hit.box_v001_3==clicked)) { isTouchCube1=true; isTouchCube2=true; } if((isTouchCube1==1)&&(isTouchCube2==1)) { Application.LoadLevel ("level1"); } //here box_v001_2 & box_v001_2 are my cube names.my logic may be right,but i know am doing wrong thing here. wht should i have to do to correct this ...?
ok no problem.... i got part of soln... in this way...
function Update ()
{ if ( Input.GetMouseButtonDown(0))
{ var hit : RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Physics.Raycast (ray, hit, 100.0))
{
Application.LoadLevel ("good_work_01");
}
}
}
so now using raycasting i can go to nxt scene.so anybody plz tel me how can use this for checking 2 or n number of cubes.
I mean to say when n number of cubes will be clicked, then only he can move to the next level
so what should be the changes needed in this code....?
Is there anybody to help me out? i'm really stucked with this problem from last 2 days...
According to above , why this is not working, what is the problem in this code? function Update () { if(Input.GetMouseButtonDown(0)) { var hit:RaycastHit; var ray = Camera.main.ScreenPointToRay (Input.mousePosition); if (Physics.Raycast (ray,hit,100.0)) { if(hit.transform.name=="box1") //here box1 is my prefab(cube) name { isTouchCube1=true; } if(hit.transform.name=="box2") //here box2 is my prefab(cube) name { isTouchCube2=true; } if(isTouchCube1 &&isTouchCube2) { Application.LoadLevel ("oops_01"); } } } } Any help will be useful.
Please do NOT flag posts as "Requires moderator attention" just because you want an answer...! Moderator attention is for taking action on posts that are inappropriate.
ok, i am trying on this way.. private var hit : RaycastHit; private var isTouchCube1:boolean=false; private var isTouchCube2:boolean=false; function Update () { if((hit.box_v001_2==clicked)&&(hit.box_v001_3==clicked)) { isTouchCube1=true; isTouchCube2=true; } if((isTouchCube1==1)&&(isTouchCube2==1)) { Application.LoadLevel ("level1"); } //here box_v001_2 & box_v001_2 are my cube names.my logic may be right,but i know am doing wrong thing here. wht should i have to do to correct this ...?
– anon62947158If i need to apply different login then also let me know.
– anon62947158C# and you will need to use the comparative on js but is almost the same
– poncho