|
Hello I'm just wondering if there is a way to give instantiated objects a unique id variable The script I am working with, and thought should work is:
The reason being I want the different numbered instantiated objects to do different things. At the moment all the objects are receiving variableInScriptAttachedToPrefab equal to the maxObjects var (12), instead of 1, then 2, then 3, up to 12.
(comments are locked)
|
|
Your logic is sound - what you have should work. However from the symptoms, it sounds like you've made your "variableInScriptAttachedToPrefab" a static variable. Remove "static" from its definition, and it should work as expected. You sir are a god, gentleman and a scholar
Apr 08 '10 at 11:50 AM
kor
(comments are locked)
|
|
You could do a few different things.
Just name that "ID.js" or something similar, and then you can get the component "ID" and check its value. Thanks for your quick reply =) But Ducks reply to simply remove "static" from my var did the trick -_-. I am using the naming, but want the scripts on the objects themselves to do certian tasks depending on thier id (ie - basing the xyz positions on 150 + id*width + id*spacing (I even tried converting the names into id vars lol :P -_-) Tags - I have been trying to avoid them as much as possible, I figured having to do the find command would be somewhat expensive compaired to just linking to the object/script directly =/
Apr 08 '10 at 11:58 AM
kor
(comments are locked)
|
