I am coming from a Unity background and there I just had a component of some custom class in the scene which I could then easily get by calling FindInScene<CustomComponent> or something like that. Not in Godot this doesn’t work, because I didn’t find a way to get the actual class of an attached script. I always just get GDScript as the class name even though I did specify a custom one.

The information I want to save are things like: where to spawn players, how many laps will this race have, maybe save references to the spawned players, etc.

So how would I save this “meta” information to get by another script in Godot?

EDIT: here is an example: I have a main scene which can load different levels. When loading a level I need to get some information about that level, like: the available spawn points. Inside each level I have a node with a script attached to it that defined class_name LevelMeta and holds the meta information that I need when loading the level. How do I detect this script and the associated meta information?

  • BentiGorlich@gehirneimer.deOP
    link
    fedilink
    arrow-up
    2
    ·
    3 months ago

    That seems very nice. Thanks for the input :) I am very much new to Godot and I gotta say most Unity systems in my head still work, but some just let me run against a wall, like the one I described here XD

    • unexposedhazard@discuss.tchncs.de
      link
      fedilink
      arrow-up
      2
      ·
      3 months ago

      Added something to the previous comment.

      Im also not super experienced, i just make unsuccessfull attempts at making games from time to time :) But i do love godot a lot.

    • unexposedhazard@discuss.tchncs.de
      link
      fedilink
      arrow-up
      1
      ·
      3 months ago

      You generally use the same logic for literally everything in godot.

      Spawning a bullet, enemy, item, ui component?

      Instantiate, set values, add_child