|
I've looked through many posts found on forum and here and still have not been able to get anything functional. I have objects that are being instantiated from functions that are called elsewhere in the script. There are 4 different prefab shapes that are instantiated from a switch/case in this spawn function. At the same time, I have another function that runs that spawns container prefabs that match whatever prefab shape is spawned from that other function (confusing eh?). The main problem is that when the spawnShape function runs it spawns the corresponding container right away. I don't want the container prefab changing right away. Currently, the moment the shape is spawned, the container spawns to latest shape. What I've been attempting is it to cache/store the spawns of the container prefabs in an array as to not switch/spawn the container to the last shape spawned, but spawn incrementally to those before the latest. I have been unsuccessful storing the instantiated objects in an array. I've attempted the many examples of storing gameobjects in arrays that I have come across... but alas, no dice. It's either hard to explain, or I'm doing a horrible job of explaining it. My apologies if that's the case. Any input is greatly appreciated. Example (hopefully easy to follow):
UPDATE: This is the functional code now working.
(comments are locked)
|
|
Are you using unity arrays or javascript arrays? Unity arrays are faster but are fixed while javascript arrays has all the standard array functions like push and shift. I was trying to use the javascript arrays so I could use .Shift. I'll adjust my code above to include the last array I attempted. I honestly may be going about this completely wrong.
Apr 24 '10 at 01:58 PM
count zero
Have you tried dumping the contents of your array in a debug log to see what's actually going on in there?
Apr 24 '10 at 03:15 PM
spinaljack
I did as you suggested with the debug.log and it was not acting as it should. Thanks for the suggestion! I took note of it and fixed a couple things. Also made a function to use rather than directly use .Shift. Thanks again!
Apr 24 '10 at 09:23 PM
count zero
No problem :)
Apr 24 '10 at 10:18 PM
spinaljack
(comments are locked)
|
