Daniel Queiroz Porto(daniel-queiroz-porto)
posted to: Firing the Hook

Usefull signal callback name pratices

I saw a convention GameDev.Tv uses in godot regarding siginal callback function names that I find really usefull!

If you're connecting the signal through the editor they leave the method's name as created by the engine with the NodeName in CammelCase as that's also their convention for node names.

But if they connect the signal through code they always do "_on_variable_name_signal_name" all on lowercase and using underscores just like the variable name.

This way you can tell by the method name not only which signal is calling it but if it's connected through the code or the editor and connected from which Node or which variable.

  • Nathan Lovato replied

    Why not! We have different guidelines, to me what's most important is to keep the callbacks close to the place you connect the signals, so you can see when the connection is established and understand its consequences.

    In Godot 3.2, you have a visual representation of connections in the script editor, so naming becomes a little less important.

  • Daniel Queiroz Porto(daniel-queiroz-porto) replied

    Wow, can't wait for that feature!

    And yeah, It totally made sense to keep the callbacks close to ready, I had never though of that but I changed to doing it with my scripts the minute you explained it in the video!