|
How do you reference objects that are created at runtime?
(comments are locked)
|
what if you have N clone's, where N is arbitrary?
Dec 23 '10 at 04:09 AM
ina
You can use an array.
Dec 23 '10 at 04:24 AM
Eric5h5
wouldn't you have to know the size of the array before declaring it? N times is unknown, and it depends on how many times the player clicks during runtime - and it's not all at once
Dec 23 '10 at 04:29 AM
ina
No, just use a list.
Dec 23 '10 at 04:39 AM
Eric5h5
okay - if these prefab's are moved after being declared, assigned to the clones variable, for example, would their transforms still be updated? - also, is it better to use tags or to just keep the variables in memory?
Dec 23 '10 at 06:50 AM
ina
(comments are locked)
|
|
Could give it a tag, if their are multiple ones (Bullets or enemies?), you could make an array of FindObjectsWithTag or whatever... If just one though, you can always just use tags. how do you assign tag's at runtime?
Dec 23 '10 at 04:10 AM
ina
Make it a prefab with the tag, and instantiate the prefab.
Dec 23 '10 at 08:41 PM
Justin Warner
(comments are locked)
|

I think what you mean is this?... you instantiate a bunch of objects at runtime, and then later want to be able to reference one or all of them, either to do something to them, or check what they're upto. Is that right?
yes basically - but they won't all be instantiated at once. depends on player input