Building Queue

Hi, I need to make a Building queue for my soldiers to spawn. You know, you come to barracks you click “E” button several times and it will spawn soldier after soldier from queue with idk, 5 sec between.

I use JavaScript.

Thanks :smiley:

:slight_smile: My question is how can I write a script that can do the queue. The unit queue you see and all RTS games.

Is there a real question here? Are you just asking for high level advice?

UnityAnswers is not a place to come and say “Please do all the work for me & write me a script that does X Y Z.”

My high level advice is:

  • Create a list or array to keep track of all units in the queue.
  • Each time the user orders a new unit, insert that unit into the end of the list.
  • Then have a “training” function or script that pops the first element of the list and has the training timer decrement.
  • When the training timer expires, produce the unit and pop the next unit from the list.

Edit: Once you’ve tried writing the code yourself, if you have problems, then you can come ask a question and get help.