So I have this class_named (the_main_node)
and im trying to reference it in another script and its not working its giving me the error " Error at (16, 22): Identifier "the_main_node" not declared in the current scope.
"
I dont know what do do I need help. The discord and didn’t fined a solution
also I cant put media in the topic bc im a new user so i will be using google drive
i dont think you supposed to reference a Node2D like that
try just load the node2d first, instantiate it, and add child it to something, then pass around the instantiated variable like what you want here
if you really want to try to instantiate by Class Name, try @onready var
You have two solutions based on whether the RigidBody2d (dragable plants) is inside the SceneTree when you start the game or if it’s added to the SceneTree after the game is run.
If the RigidBody2d exists on runtime, then you can create an @export variable for your root node (in your case it’s called “the_main_node”)
change your the_main_node2 to this: @export var the_main_node2: the_main_node
open up your main SceneTree, click on your RigidBody2d, assign the exported variable to be your root node
If your RigidBody2d is added after runtime, write a method that you call after instantiating the object
add the following method to your RigidBody2d script