How sample(instance) of an object?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By abbos

How can I take a sample of an object?
Like a hundred squares coming down from the top of the game scene

I’m not sure what you mean by “take a sample of an object”. Maybe you can provide some more detail?

jgodfrey | 2020-07-09 21:18

To copy a large number from one (kinematicBody, sprite, collisionshape) but in script

abbos | 2020-07-10 03:06

:bust_in_silhouette: Reply From: Siandfrance

If you want to create a lot of them from script you can do:

var MyNode = preload("path/to/the/node.tscn")

and:

var new_node = MyNode.instance()
#if you want to change something in the node (for example the position here):
new_node.position = new_position
scene.add_child(new_node)

to instance one. Then just use a for loop to create hundreds of them.