- Home /
I have an array problem
I'm basically trying to create a sort of a line that will wait for the first triggered before moving on to the next.
If that didn't make sense, think of an RTS where you can queue your research and spawning on top of each other.
I have hashed together an idea I had using an array but it doesn't seem to work after the first trigger. Here's the code:
Okay, couldn't get the in forum code formatting to work, so here's a pastebin link
The array just stops working and registers any more strings for a only frame after the first action completes, effectively doing nothing.
Also, if my scripting is bad and makes your head hurt, I apologize, I still consider myself a novice and I've been too busy to find and do advanced tutorials. Bear with me.
Also, it seems very cumbersome to do it my way, so if you have any suggestions of other ways, I'm all ears. I can be flexible.
EDIT: I have tried several different setups with queue, every single one runs with no errors but doesn't work with the if statement. I don't know if it's my fault or unity. I have tried: using .Equals(object) inside of an if statement, .Equals(object) as a boolean, .Peek = object inside an if statment.
The Array class is worthless for everything. I think Queue is what you're after. http://msdn.microsoft.com/en-us/library/7977ey2c.aspx
Seeing as how reposting isn't enjoyed by any community, I'm going to do my best to bump. I need an answer and will not close this question til I get this working. Queue works up until the first object needs to be called. Can't figure out what's wrong, because there isn't much documentation on unityscript queue. Here are some examples of my attempts: http://pastebin.com/CUauNYYT
You can keep posting until you're blue in the face, but it's not going to do you any good... the question you have is a basic program$$anonymous$$g question, not a Unity question. You need to go back and read a c# or javascript book, because this is very basic program$$anonymous$$g.
Answer by Diablo · Apr 19, 2012 at 12:12 AM
Jessy is correct, what you need is a Queue. Queue's work on the FIFO (First In, First Out) principle, so you can keep queueing multiple things up and fetch things one at a time as you're ready.
Is there a javascript equivelant of queue? If so, do you know of any documnetation? I really don't want to learn C# at the moment, but I guess I will if I have to.
Edit: I figured the javascript grammar for it out, but it doesn't seem to function at all though. Still would like some documentation. i'm not really sure what I'm doing function wise...
Your answer