Why use Notification? Godot 4 C# Action Adventure 3.4

Is there a reason to use the built in godot _Notification method over a custom method to handle enabling and disabling states? What are the benefits?

There’s certainly nothing stopping you from building custom functions to do this, but my understanding is that Luis decided to do it this way, first and foremost, because the notification system already exists.

In general, if you can utilize an underlying system to help you do what you want, that solution is likely to be more performant because there are fewer “layers of translation” if you will. This is especially true in Godot since everything is using C++ under the hood, so the more you can directly leverage that, the better, and notifications are engine-level, so they do.

Because of what notifications are, this way of doing things also significantly simplifies the matrix of signal connections that you would otherwise most likely be using. I do feel his use of magic numbers in the conditionals is not ideal (not least because the number itself has no inherent meaning to it), but on the other hand, that does leave room for a nice extension that students can try to build on their own. Hope that all makes sense =)

1 Like

Thanks for the response. Godot gets kind of confusing with having C++ ‘under the hood,’ gdscript default, and C# as an alternative. Is there a good place to learn about the specifics of it and how it affects decisions you make?

1 Like

Yes, it can definitely feel a bit unusual, especially when you consider how fundamentally different GDScript is compared to C-series languages. Basically, because of the difference in performance between the 3 languages, any built-in feature (a node, a signal, a provided function, etc.) is very likely (not 100% guaranteed) to be more performant than something you build yourself, just because that built-in feature is made using C++, which is a lower-level language than the other two. This fact actually has nothing to do with Godot itself; that’s just how the languages are (in fact, C# as an actual language is, itself, made using C++).

What might be useful to you is to have a look at the entire Introduction section of the docs:

A lot of what is shown there, you will already know from the courses, but it also explores many of the more abstract features regarding why the engine works the way it does.

Along the same lines, I would also skim through the Best Practices section and read through anything that catches your eye, since it’s more about Godot-specific things than general “best practices that every programmer should know.” There’s some great stuff in here!

“RTFM” is probably not the answer you were expecting, but honestly, Godot’s docs are quite good in comparison to the MSDN for example. Worst-case scenario, if you read something in the docs and you don’t understand it, you’ll at least have the proper terminology to research it elsewhere. Good hunting =)

1 Like

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

Privacy & Terms