• Godot HelpC++
  • Is it possible to bind a static method or a global function?

Hello!

I'm using several functions I'd like to have implemented in C++. But I'm not sure how to bind a function (or a static method) such that I don't need to create a dummy object every time I need a functionality.

I'd appreciate any help! Thank you!

  • Autoload is inside the editor in the project settings.

Is this Godot 3 or 4? You can try putting the C++ object as an Autoload (Singleton basically) so it is available globally in Godot.

  • z80 replied to this.

    cybereality
    Preferrably Godot 3.x. Strange, I'm searching "autoload" inside the Godot *.cpp and *.h and nothing pops up. Would you please explain how to implement the autoload you've kindly mentioned.

    Is it different in Godot 4?

    Autoload is inside the editor in the project settings.

    • z80 replied to this.

      cybereality
      Ah, that autoload. Thank you! Yes, that's probably a valid solution. I can create a Reference derivative and throw all my functions inside.
      Thanks again!