#GetNode failing silently

1 messages · Page 1 of 1 (latest)

sick sinew
#

I'm very new but seemingly have a strange issue where GetNode does not work, but also doesn't print any error. I have this in my main _Ready():

GD.Print("Main1!"); handDisplay = GetNode<HandDisplay("HandDisplay"); GD.Print("Main2!");

The program seems to stop and not print 'Main2'
=>
Main1!

If I use the safe method

GD.Print("Main1!"); handDisplay = GetNode<HandDisplay("HandDisplay"); GD.Print("Main2!");
Then it can get past this line
=>
Main1!
Main2!

The GetNode() documentation says " If the path does not exist, a null instance is returned and an error is logged. " So, I'm confused. This seems like this should be really obvious but why isn't there an error log or exception?

I'm using Rider C# / Mac / Godot 4 if that makes a difference.

vocal shuttle
#

Missing a > there

sick sinew
#

ah yeah, in the question whoops

#

the code is correct

vocal shuttle
#

So if that is correct, what do you mean you cannot "get past this line"?

#

What is happening?

sick sinew
#

I'm trying to figure out why the second print doesn't happen

#

it's as if execution stops but there's no exception or error printed

vocal shuttle
#

Nothing shows up in the Output tab and the Debugger tab?

sick sinew
#

oh it's in debugger!

#

Unable to cast object of type 'Godot.Node2D' to type 'Slay.scenes.cards.HandDisplay'.

#

thanks

#

I didn't realize errors don't always show up in output

#

well I have no idea why its the wrong type but I guess that's another thing lol

vocal shuttle
#

Or at the very least, make it toggleable in the same window

#

Good luck ^^

sick sinew
#

thanks!

#

do you have any idea why when I do this:
public partial class HandDisplay : Node2D

#

but on main > instantiate scene > HandDisplay its not Node2D and not the subclass?

vocal shuttle
#

Can you show your scene?

sick sinew
#

so I can load the node as long as I do Node2D not try to cast to HandDisplay

vocal shuttle
#

I don't see a script attached here

sick sinew
#

but then for whatever reason HandDisplay has no read() called

#

oh..

#

I thought I did that but you're right! it's not there

#

ok that fixes it for real

#

thanks!

vocal shuttle
#

awesome