0 votes

I'm working on a 2d rts type of game, as always it needs a barracks I'm new and after searching for a long time I figured I'd come and ask you guys. I have a troop model, a building/barracks model and a simple ui. I want to be able to queue troops and spawn troops.
I'm new to godot and game dev as a whole. I understand this is a big step but this is the way I learn.
your help will be appreciated :).

Godot version 3.1
in Engine by (12 points)

1 Answer

0 votes

Probably the easiest way to accomplish this is to:

  • Preload the troop scene(s) in the barracks script.
  • Add a variable for the number of queued troops. If they need to be of different kinds, you could use an array instead.
  • Create a timer and connect its timeout signal it to a function where you pop an item from the queue (or simply decrease the number of queued troops), then instance a troop, then reset the timer if anything is still left in the queue.
  • Connect your UI button to a function where you add an element to the queue and start the timer if there were previously no elements.
by (1,305 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.