#PackedScene from resource
1 messages · Page 1 of 1 (latest)
have you successfully stored the resource to initialize, and linked it to a node as an @export?
By storing the resource do you mean like doing the preload of nameofresource.tres ?
Also by linking it to a node as a export do you mean
@export var VarName: PackedScene
Inside the resources script?
Sorry I’m pretty new to this
I have this for the code
Extends CanvasLayer
const IDX = preload(“res://Monsters/ID0.tres”)
func _ready():
var monsterY := ID0.battle_graphics
var monsterX = monsterY.instantiate()
$Enemy.add_child(monsterX)
It worked with that code^
I somehow solved it maybe I messed up something earlier and fixed it but I’ve been trying for 2 days doing something very similar to the code above to get it to work. But that works
Turns out you can do it with
var monsterX = IDX.battle_graphics.instantiate()
$Enemy.add_child(monsterX)
battle_graphics is the name of the variable in my resource that holds the packed scene
Hope this helps anyone who has been having trouble