I am trying to pass a PackedScene from one Node (itself) to my GameController.gd where I want to then pass to my ItemList. My issue is that my PackedScene variables always returns null
I have created my collectable as so:
- 2D Node (called ExtraJump)
--- Area2D
------CollisionShape2D
------Sprite
I have a script attached to ExtraJump which looks like:
extends Node2D
onready var collectables_controller = get_tree().get_root().get_child(0).get_node("CollectablesController")
class_name Collectable
export var CollectableItem: PackedScene
export var collectable_name: String
export(Texture) var icon
func _on_Area2D_body_entered(body):
if body.name == "Player":
print(CollectableItem)
collectables_controller.collect_item(CollectableItem)
I have dragged my ExtraJump.tscn file into the CollectableItem space in the inspector, but it prints out null and does not pass anything to my colelctables_controller.
Where am I going wrong?
Thanks