I'm attempting to instantiate a node the way that I've done many times before, and for some reason I don't understand its _EnterTree() isn't getting called. I assume something I'm doing is causing a silent failure under the hood, but I don't know what it would be.
// In a separate .dll that my main game is referencing
public partial class MyCustomMultiplayerSpawner : MultiplayerSpawner
{
public override void _EnterTree()
{
GD.Print("Entered tree");
// other more important logic too
}
}
// In my main game
var spawner = new MyCustomMultiplayerSpawner();
spawner.Name = "Spawner";
Node parent = <some other node>;
Debug.Assert(parent.IsInsideTree()); // succeeds
parent.AddChild(spawner);
I would expect _EnterTree() on the spawner to be called as part of the last line there, but that doesn't seem to happen and I can't figure out why not. Is it a problem that MyCustomMultiplayerSpawner is in a separate .dll? Do I need to create it in a different way or something?
Thanks for any help!
(I could manually call _EnterTree(), but it seems like this issue is indicative of more stuff going wrong; I also set the MultiplayerSpawner's SpawnFunction from within there, and that's failing with ERROR: Custom spawn requires the 'spawn_function' property to be a valid callable. which I assume is related to the fact that this spawner isn't considered to be a valid node in the tree. Although when I print a list of parent.GetChildren() I do indeed see the spawner there, so 🤷 ).