Material Box

Material Box

WEB Design & Material Images

Godot - Create an instance

Godot

Introducing how to create an instance in GDScript.


instantiate() creates a node from a resource loaded with preload() or load().
The created instance is displayed by adding it to the node tree with add_child() etc.

var item = preload("res://item.tscn")
# var item = load("res://item.tscn")

instantiate = item.instantiate()
add_child(instantiate)

It is also possible to describe instantiate() within add_child().

var item = preload("res://item.tscn")
# var item = load("res://item.tscn")

add_child(item.instantiate())

Godot

TitleGodot - Create an instance

CategoryGodot

Created

Update

AuthorYousuke.U