Duplicating/cloning in godot

Godot Version



When I create a clone in godot using duplicate() how do I set the clone to do something as soon as it is created. Would func _ready(): work?

To create a clone of everything would I use just duplicate() or would I use duplicate(15), or something of the sort?


Im a Scratch programmer so I want something that will work like “When I start as a clone” so I can assign a variable to it that it checks what animations/hitboxes it should have via if statements.

you can do this

var clone = object.duplicate()#i don't know duplicate method there might be mistakes
var justCreated = true
if justCreated:
    do something
    justCreated = false

_ready won’t help
_ready works only on scene’s beginning

1 Like

if your duplicated object has a script that do something at _ready(), then it should work
but remember to add_child(object) after it’s duplicated, else it wont work

above is for Nodes
_ready function is basically the first method it run after the Nodes got added into scene tree, so why it needs that add_child after duplicated