Hi, I have a bunch of hex tiles instantiated on world generation
for(...)
Spatial p = (Spatial)LandHex.Instance();
p.Translate(new Vector3(x, y, z));
AddChild(p);
and so far all good. Then through a button I try to instantiate a scene with a couple of models, pretty standard stuff I imagine:
public void _on_ButtonFarm_button_up()
{
GD.Print("Farm loaded");
if(Hexagon.selectedHex != null)
{
Spatial p = (Spatial)Farm.Instance();
Hexagon.selectedHex.AddChild(p);
}
}
Now, the farm doesn't show up here, but if instead of hexagon.selectedHex.AddChild(p) I just do AddChild(p), which will bind it to the button itself, it appears just fine. I have also attempted to Translate() it, Scale() it etc, just in case. Inspection in the editor with Remote does not show anything abnormal, all transforms etc have non-zero values.
Any ideas?
I have also tried doing .setVisible(false) on the tiles to make sure they're not hiding it, and .setVisible(true) in case it inherits the visibility, but the child is nowhere to be seen.
The nodes:
Hexagon:
KinematicBody
hexagon (Spatial)
StaticBody (model with attached Hexagon.cs script)
CollisionShape
Farm:
Spatial
Spatial (with the actual model)
When I run it and switch to Remote, I see the farm attached under the StaticBody, which I expect since that's where the Hexagon class lives