I have a node - ObjectPosition, which I use as a resource, for the ecs pattern
This node stores a boolean variable, which changes its value depending on certain conditions - IsColliding
Also, this node is a child object of the node - Object
In the Main script, I spawn the Object node, and after the moment of its creation, through its child node - the GetChildren<T>() method, - I want to know the state of the boolean variable -IsColliding
But! I can’t do this. Godot sees only the base state of the variable
It feels like when trying to access
Object.GetChildren<ObjectPosition>(0).IsColliding
Godot does not look for this variable in the current instance node, but in its other instance (otherwise I don’t know how to explain it)
Resources are shared between all instances by default, for performance. If you’re making multiple instances of a scene that need their own copies of the resource data, then click “Local to Scene” in the resource (under the resource header in the resources exhorted l exported variables).
To do similar in code, you can assign a resource using resource.duplicate()
To duplicate a resource in the editor making a new copy, you can select “make unique” in the resource drop down menu
I’m not sure if it will be very clear, but I need to remove the Object node I mentioned earlier, by checking the ObjectPosition of the IsColliding variable.
I tried using the Duplicate() method in the code, but it gave me 800 lost nodes
Yeah; I was too tired when I read your original post. I see now you are using a Node and not a Resource object, so what I said above doesn’t apply here. (The Node object also has a “duplicate” method which is useful, but maybe not relevant here.)
I would use the debugger to pause the code here and check in the scene tree to make sure the Node you want to look as has the value you think it has, and go from there.