When creating a new Sprite3D node via script, it is not visible

Godot Version 4.2
I have a function drop_item(item)
item is a TextureRect
The idea is that when the function is triggered in owner node World, it creates a child node with the dropped Sprite3D object (something similar to Don’t Starve because I use billboard), but when I do add_child, the texture is not loaded. I checked everything I could through print(): position, loading texture into new node, whether add_child happened, but it is still not visible, help please :slight_smile:
P.S. player_position is not a reference to player in the Ready function (because I have a little bit failed there :slight_smile: ), so I pass the position of the character from the character script to the global script (where the drop_item is located, respectively) (everything works in this respect).

What does Remote tab say after you supposedly add a new sprite child?

Is it actually added?
Does it actually have a texture?
Is the position correct?

I used print() to do the check. The node is created, I checked this by looping for child in children, the position and other things written in the script are assigned to the new node correctly.

I’ve solved the problem.
The script on the screenshot I loaded in autoload and did not want to bind it to the node (i.e. to make just a global script). I connected the World node via instantiate in the ready function in the global script. As I understood the instantiate method allows you to change the scene not in real time, and I thought that in real time, that is, all the changes I made to the World node worked, but to display them, I had to re-enter the scene (which would be bad for optimization). So I decided to connect the script directly to the World node and now by passing an item to the drop_item function, everything worked.
P.S. About instantiate this is just a theory that my brain has reached, because I did not find information about it on the official wiki page. So if anyone is interested, you can check my theory in reality :slight_smile:

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