- Home /
gameobject list
hi what i am trying to do is simply use a gameobject.find("checkpoint") but with a changable number at the end so im looking for the keyword checkpoint but all my objects are numbered so i need to put this at the end. but it has to be able to change number.
in short i need a way to say gameobject.find("checkpoint")1 but the 1 will eventually change by another script. so where do i put this 1 which is a varible named check
Answer by reptilebeats · Feb 26, 2012 at 11:39 PM
ok so took me a while to finaly click in my head i was using && instead of + dope.
var CheckPoint : int = 0; ("Start(Root)"+CheckPoint)
Answer by Talas21 · Feb 26, 2012 at 11:22 AM
If you are looking for a way to access a variable inside a script attached to the object "checkpoint", you should use this code:
GameObject.Find("checkpoint").GetComponent("ScriptAttached").check;
You can also modify it or assign it to another variable. You can use the same way to call function inside other scripts:
GameObject.Find("checkpoint").GetComponent("ScriptAttached").FunctionToCall();
no im looking for a way to change a gameobject.find("name").
so i have check1 check2 check3 check4
so what i want is gameobject.find("check")
and then have the last part of the name change by varible so the same code works for all my objects, but i cant use tags as this wont work as each object needs to change at a specific time
Your answer
