Topic was automatically imported from the old Question2Answer platform.
Asked By
Arc Futahito
Old Version
Published before Godot 3 was released.
I have a class in my singleton that I need to access from another node. I set up a reference to it with get_node(“/root/global”).Character.new()
Trying to get variables from it just throws me “Identifier not found” error.
I know you can set a separate gd file as a class and “extends” from that, but it’s a really small bit I’d like to have in global for convenience.
Is there a way to call inner class from other gdscript?
It’s not about calling inner class.
But this can be solved.
in global, add function to return Character.new()
func new_character():
return Character.new()
and use this function
var new_char = global.new_character()
new_char.set_name("tom")
Thanks a lot. Tried it yesterday but didn’t work for some reason (that’s what I get for writing code past midnight) but now everything is fine. That should do it.