Possible to instance more than once with code that runs once?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Kavi
:warning: Old Version Published before Godot 3 was released.

Hello!

I’m working on a zombie project game and I was wondering if it would be possible to instance 2 things at once without doing it really fast in _process(delta).

Ex: var E = enemy.instance() # is it possible to instance 2 here instead of one?

or

Ex: add_child(enemy) # is it possible to add 2 child's to the scene instead of one?

Instead of copying and pasting the whole instancing.

Any ideas/Help would be awesome c:

use a for loop?

whooshfrosted | 2017-05-26 22:02

What do you mean with “without doing it really fast”?

Something like using a timer, spawn when starts and on timeout?

eons | 2017-05-26 23:57

there will be no time to run any other codes if you let them.
as @whooshfrosted, @eons said,
if you run this,

var E = enemy.instance()
add_child(E)

no other things can’t be run during running this 2 codes.

if you do this below, nothing can happen but enemy is generated eternally and will get only not respond message from OS.

while true:
    var E = enemy.instance()
    add_child(E)
  • what are you trying to do?
  • what did you expect?
  • what is your problem?

volzhs | 2017-05-28 19:17

you can use for loop, if condition, while, or just copy and paste the code//

Phil88n | 2017-06-19 14:27