use two component in one game object

I got 5 cubes

if ı click first cube’ bool=true

after I click second if first cube bool== true I can go on

after I click third if second cube bool ==true I can go on

after I click forth " " " " "

after I click five " " " " "

problem is I complete the click with this order 1-2-3-4-5

I want add new order

new order 1-2-3-4-5-2

if ı click cube 2 after 5 cube 2 can’t see cube 5 bool it still use first cube bool by the way script give no error

I use this 2 times in second cube

void OnMouseDrag (){

if (GameObject.Find (“cube1”).GetComponent ().boolean ==true)
debug.log(“Keep”);

if (GameObject.Find (“cube5”).GetComponent ().boolean ==true)
application.loadlevel(“menü”);

I need help very much please help me

I think am not getting this correctly… but first of all, in “GetComponent” is “cube5” a class? It seems like not at all and that will give you errors… and if it is, thats not the way of handling them (cube1, cube2… cube5)… Also, what’s with this variable “boolean”? Is it a member of “cube1”?

Your code is a little confusing :S

("Cube1’') is gameobject. is a script scripts carry boolean after one with this code

Based on what I could gather, you can just add one more bool in Cube2 script and then
set it to true once it has been clicked after cube 1 click :

bool alreadyClicked = false;

void OnMouseDrag (){

if (alreadyClicked == false && GameObject.Find (“cube1”).GetComponent ().boolean ==true) {
debug.log(“Keep”);
alreadyClicked = true;
}

if (alreadyClicked == true && GameObject.Find (“cube5”).GetComponent ().boolean ==true)
application.loadlevel(“menü”);

Regards

1 Like

thats what im talking about :smile:

thanks so much my friend it’s work done great

I need one more answer

all order work now 1-2-3-4-5-2

but I want =

player completed order 1-2-3-4-5

the all cubes true now he can click all without crash because all cubes support behind (bools are true)

But I must do this (this is the last one I want)

maybe this will be hard

I want just support behind

so = I click first cube first cube = true
I click second cube second cube = true

İf ı click third cube first cube boolen must turn false from true

cube 1 true must false

Glad it helped you !

Not exactly sure what you’re looking for, but
maybe you can just set the bool to false when the click is detected. So in cube 2
or cube 3 script, you can just write this :

void OnMouseDrag () {
GameObject.Find (“cube1”).GetComponent ().boolean = false;
}

and in cube 3 or cube 4 script, you can just write this :

void OnMouseDrag () {
GameObject.Find (“cube2”).GetComponent ().boolean = false;
}

…and so on for other cubes.

Regards

yes it work thanks bu there is still problem I click cube 1 cube bool = true click 2 if 1 cube bool == true ı can go on

I come third and if I click third first cube boolean turn false there is work great but problem is I write this in cube 1

void OnMouseDrag() {
boolean = true;
debug.log(“firstwork”);

if (GameObject.Find (“cube1”).GetComponent ().boolean ==false) {
Debug.Log(“gameover”);
Application.LoadLevel(“gameovermenü”);

I want see gameover menü but When ı click second time first cube nothing change on scene

by the way my public bool boolean ;
so I write nothin it turn false

problem is booleans are conflict each other when I turn again first cube second time it still use boolean=true I think

Hmm this is just a guess again, because I’m not sure what you want to achieve.
You can keep a count of clicks in cube 1 script like this :

int cube1ClickCount = 0;

void OnMouseDrag() {

cube1ClickCount++;

if(cube1ClickCount == 1) {
boolean = true;
debug.log(“firstwork”);
}

if (cube1ClickCount > 1) {
Debug.Log(“gameover”);
Application.LoadLevel(“gameovermenü”);
}

you are the man :smile: I think it work I hope D