Inventory loads in but when attemtping to add an item in panel, it crashes,

Godot Version

Godot v4.2.1.stable

Question


keybind set to load in the item, item is a scene script, changing to preload item instead of inventory.tscn
image
error mesedge ^

when i press L it crashes.

In Godot 4.x instance() got renamed to instantiate()

also when in doubt you can use can_instantiate

extends Node2D
var m_sprite_scene : PackedScene = preload("res://sprite.tscn")
var m_sprite : Node2D = null
func _ready():
	if(true == m_sprite_scene.can_instantiate()):
		m_sprite = m_sprite_scene.instantiate()
		add_child(m_sprite)
	else:
		print("bad hair day")

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.