How to Use Signals in Godot 4 - Editor vs. Code

preview_player
Показать описание

Early Access Starting Jan 30

------------------------------------------
🖋 SYNOPSIS

This video introduces signals, a fundamental feature of Godot that you use to run a piece of code when an event occurs in the game. For example, when pressing a button, this button node emits a signal named "pressed". If you connect to that signal, upon receiving it, you can run code that opens a menu, opens a link in the browser, purchases an item in the game, and so on. The video shows the two different ways to connect signals in the engine: using code, and using the editor interface.

-------------------------------------------

*CC-BY 4.0 LICENSE*
Рекомендации по теме
Комментарии
Автор

I can't believe people are complaining about your paid content/courses or ads, in the face of all the awesome free content you've provided *and* the quality of all your content. Please keep creating and to anyone reading, please keep supporting! ✨

ahnmichael
Автор

One trick when connecting through code:
If you have multiple entity, say 30 buttons connecting to single function, you can use bind() to detect which entity sent the signal.
For example,
for button: BaseButton in buttons:
->|
Then have an argument in is_button_pressed, it'll be able to tell who sent the function.

Evitrea
Автор

It's worth noting, rather then a open and close animation, you can make an open animation and tell godot to just run it backward. That's what I'm doing in with a stasis pod in my project.

ahettinger
Автор

You Missed what I think is the absolute most crucial thing about signals. Generally, if you set a variable in another node to something, that node will not perform any processing until its "turn" in _process, signals immediately call the function even if it's in a different node. Understanding the placement of signals is very important, and can be used to change stuff immediately, rather than waiting till the next full run of all _process() calls

LmAnubis
Автор

These latest tutorials are so sharp! Love the little animations. GDQuest raising the bar again!

DarthLateralus
Автор

i already know how to connect signals in the editor
but thank you for showing how to connect them in GDScript:

this is very convenient to connect the Node's own signals
and the only way to connect signals of Autoloads

sosasees
Автор

Could you please make an intermediate tutorial about about finite state machines for a player character with 2D-movement (e.g. top down). There aren't many good tutorials about it, the ones that exist are too basic and don't really help when you try to build one.

PunCala
Автор

Nice... Finally understood how to use signals, IDK how I didn't get it even though I work with Java Listener before

ahmadamir
Автор

Love the vids, and I just payed for your early access. Can’t wait. Is there an easy way to connect to signals if they’re not in the current scene tree ?

OldM
Автор

nice.. following the concept of Qt signal/slot. i like this.

ningyi
Автор

signals is so hard for me to comprehend.
but 4.x is a slight improvement in fitting it in my grey matter

knerf
Автор

Does Godot have an efficient, intuitive way to register signalling nodes to a list and then have others listen for signals from that list?

My understanding of how this pattern should work is that it's preferable for signals to just be fired in the void, and the source node should not have to care who the listeners are.

htspencer
Автор

what is the difference between a property and a method ? Sorry, basic question, but I still don't get it after a few hours into Godot :D !

Blender.Quebec
Автор

I don't like the fact that you connected a node's signal (i.e. _on_body_exited() ) to itself [7:12]. I usually imagine child nodes of a scene sending signals up the scenetree instead.

The way I would fix this is to change the base node of Door3D from an Area3D into a Node3D, and make the Area3D into a child of the Door3D scene. (naturally, the CollisionShape3D will become a child of the Area3D)

so the Door3D scenetree would look like this after the changes

Door3D(:Node3D)
|- Area3D 🛜
| |- CollisionShape3D
|- AnimatableBody3D
|- AnimationPlayer
|- Model
|- StaticBody3D
|- Sound

So the _on_body_exited() signal will be sent up the scenetree to the script of Door3D, which will in turn control the AnimationPlayer.

Anyway, if there were any mistakes I've made, do point it out.

arifnajwan
Автор

Nice. Regrettably didn't teach me anything new. Trying to puzzle out a "press E to interact" game mechanic via components and signals. I have a component that transmits raycast collision objects (and if it it doesn't have anything) just fine, the next two components, the transmit/receive interaction components haven't been panning out. I probably need a different tutorial.. maybe one more specifically about that type of interaction being done.

purpletrauma
Автор

I was struggling, I couldn't figure out why I was able to get the debug to print, but not change the visibility. but I guess you can't do this if there is a Script attached to the Button that you want to %Access as a Unique Name. just posting in case anybody else runs into the same problem. thanks for the video!

markfurlong
Автор

Do the courses teach in an interactive style similar to the free intro course? I completed the free one, and absolutely loved it. :)

mayedalshamsi
Автор

how do you make the wiggle effect on the sprites at the beginning of the video? is it a shader, or is it just an editing effect?

galaxius_games
Автор

What if I am using a custom signal, how do i emit it when for example it collides with the player?

sachapotato
Автор

I tried to activate a function of a child node of another scene by pressing the button called (_si_button) of a dialog in the world scene I created the si_presionado signal in autoload it doesn't work for me why? my idea is that when you press the button (_si_button) in the world scene then the function _on_si_presionado() is activated in script(ui)

Necrincito