Function naming convention

Just a small point. In the Alien Attack video where a VisibleOnScreenNotifer2D node is being used to signal when the rocket exits the visible screen area I see that we are creating a function called _on_screen_exited(). It was mentioned in an earlier video that special functions called by Godot normally start with an underscore. I guess in this case, even though it’s a user-defined function, it’s still Godot calling it, so this is still conforming to the convention. I suppose in general, any callback function should start with an underscore?

aye, the trailing underscore (_) as far as i understand it is more a convention to indicate that a method or function isn’t called directly, but more called by the engine in response to an engine event.

there is other talk of using the _ for privately declared/used methods within a class, but its my understding that theres not really any notion of public/private within godot.

yep, thats my take on the signal connection, whether we connect the signal event via the UI, using its default signal name (or customize the name using the advanced tab) or via code.
were tying in the receiver method to that event.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms