You know, I have a degree in game programming and a good amount of experience in Unity, Unreal, and now diving into Godot. And events/signals have always been something I personally took a long time to wrap my head around. But man, if a professor would have explained them like this back in school, I probably would have had a much easier time. Lmao.
Honestly if it wasn't for your videos I would've given up on Godot forever ago. THANK YOU! You are like the only person on RUclips doing Godot C# tutorials
I'm super happy to be of service! I'll keep pumping them out for you, and hopefully, the Godot C# community will start to grow so you won't only have to listen to me drone on and on :D
I love how simple and straight forward you present this. I've seen so many videos when I was learning about events back in the day that got into the weeds rather then showing simple use case examples first to get people comfortable with it. Because of that events were this confusing black box for way too long for me. I wish I had seen a video like this on events back then. Great job!
I was looking forward to this video, it helped so much, thank you! I'm not 100% there on how the syntax is working with how you've explained the delegated functions though. In the context of the timer code you made at 12:00, is _timer.Timeout accessing a list of methods in the _timer object then, and adding to that?
You are correct. Timeout is the name of a delegate in the Timer.cs class. So when you do something like "_timer.Timeout += OnTimerTimeoutSignal;", you're adding the OnTimerTimeoutSignal method to the delegate Timeout which lives on the specific _timer. Then when the timer hits zero, it emits Timeout, which is the same as saying "all of the methods added to Timeout get called."
To my knowledge, yes. Signals are built on top of C#'s already existing event system, so for responding intra-language, I'd assume it's an Invoke call behind the scenes.
C# events are not serializable to the best of my knowledge. The only reason custom signals show up in the UI is because of Godot voodoo (one of the reasons you have to add "EventHandler" to the end). Other than showing up in a list in the Node tab, I can't think of how having them showing up in the UI would be useful though.
northBox.BodyEntered += OnNorthBoxBodyEntered; northBox.BodyExited += OnBodyExited; how you said i should do it vs how i was doing southBox.Connect("body_entered", new Callable(this, nameof(OnSouthBoxBodyEntered))); southBox.Connect("body_exited", new Callable(this, nameof(OnBodyExited))); pretty wild one is alot easier to use yet the docs tell us to do it another way. Ill be looking forward on your Events video.
does this work in scripts where the thing you wanna emit is a child of the node? For example i have a tranisiton scene, that has a child animationplayer, im trying to emit a signal when the animation finished playing. In the ready of the transition scene i cannot do
private AnimationPlayer animationPlayer; public override void _Ready() { animationPlayer = GetNode("AnimationPlayer"); animationPlayer.AnimationFinished += OnAnimationFinish; } i get an error stating no overload for OnAnimationfinish(string) matches delegate AnimationMixer.animationfinishedeventhandler. im forced to do animationPlayer.Connect("animation_finished", new Callable(this, nameof(OnAnimationFinish)));
Sorry I'm getting to this late - had work stuff to handle this week. Your OnAnimationFinish signal handler needs to take a StringName as a parameter, not a String. So if you make your method signature look like this - private void OnAnimationFinish(StringName animName) Then it looks like your code would be fine.
You know, I have a degree in game programming and a good amount of experience in Unity, Unreal, and now diving into Godot.
And events/signals have always been something I personally took a long time to wrap my head around. But man, if a professor would have explained them like this back in school, I probably would have had a much easier time. Lmao.
Yay! I'm happy I could help!
Honestly if it wasn't for your videos I would've given up on Godot forever ago. THANK YOU!
You are like the only person on RUclips doing Godot C# tutorials
I'm super happy to be of service! I'll keep pumping them out for you, and hopefully, the Godot C# community will start to grow so you won't only have to listen to me drone on and on :D
This process is very unclear in the docs
it's very helpful, thanks!
You have a real talent for teaching, this was excellent thank you
Your stuff is just pure gold man !
Excellent video, you have a good teaching style.
I like it how you have a drawing on the whiteboard on each frame and video, love your efforts
Thank you! I love to add the touches when I have time :D
this helped me so much wow i was so stuck all day trying to send the fruit count from my player to a gui element lol
Yay! I always love hearing about helping folks. Good luck on your game!
That video is fucking awesome
Your videos are a god-send. I love every single one. Keep up the great job.
Will do! Got another uploading for you right now.
You explain things very clearly and with examples, I appreciate it
Best signals guide for godot C# i've seen so far. Thank you!
You're very welcome. Just put one up on events for you, if you're interested.
really good video!
I love how simple and straight forward you present this. I've seen so many videos when I was learning about events back in the day that got into the weeds rather then showing simple use case examples first to get people comfortable with it. Because of that events were this confusing black box for way too long for me. I wish I had seen a video like this on events back then. Great job!
Thank you @alapidis, I appreciate the kind words!
Thanks bro🎉
Great stuff! Keep it up!
I was looking forward to this video, it helped so much, thank you! I'm not 100% there on how the syntax is working with how you've explained the delegated functions though. In the context of the timer code you made at 12:00, is _timer.Timeout accessing a list of methods in the _timer object then, and adding to that?
You are correct. Timeout is the name of a delegate in the Timer.cs class. So when you do something like "_timer.Timeout += OnTimerTimeoutSignal;", you're adding the OnTimerTimeoutSignal method to the delegate Timeout which lives on the specific _timer. Then when the timer hits zero, it emits Timeout, which is the same as saying "all of the methods added to Timeout get called."
I suspect that emitting a Godot signal involves a P/Invoke behind the scenes, is that correct to your knowledge?
To my knowledge, yes. Signals are built on top of C#'s already existing event system, so for responding intra-language, I'd assume it's an Invoke call behind the scenes.
Is there a way to use C# events and have them show up in the Godot UI?
C# events are not serializable to the best of my knowledge. The only reason custom signals show up in the UI is because of Godot voodoo (one of the reasons you have to add "EventHandler" to the end). Other than showing up in a list in the Node tab, I can't think of how having them showing up in the UI would be useful though.
@@arkadegamesllcever created custom windows.forms controls for use with the VS designer? Similar voodoo
northBox.BodyEntered += OnNorthBoxBodyEntered;
northBox.BodyExited += OnBodyExited;
how you said i should do it vs how i was doing
southBox.Connect("body_entered", new Callable(this, nameof(OnSouthBoxBodyEntered)));
southBox.Connect("body_exited", new Callable(this, nameof(OnBodyExited)));
pretty wild one is alot easier to use yet the docs tell us to do it another way. Ill be looking forward on your Events video.
Events video is up!
does this work in scripts where the thing you wanna emit is a child of the node? For example i have a tranisiton scene, that has a child animationplayer, im trying to emit a signal when the animation finished playing. In the ready of the transition scene i cannot do
private AnimationPlayer animationPlayer;
public override void _Ready()
{
animationPlayer = GetNode("AnimationPlayer");
animationPlayer.AnimationFinished += OnAnimationFinish;
} i get an error stating no overload for OnAnimationfinish(string) matches delegate AnimationMixer.animationfinishedeventhandler.
im forced to do animationPlayer.Connect("animation_finished", new Callable(this, nameof(OnAnimationFinish)));
Sorry I'm getting to this late - had work stuff to handle this week.
Your OnAnimationFinish signal handler needs to take a StringName as a parameter, not a String. So if you make your method signature look like this -
private void OnAnimationFinish(StringName animName)
Then it looks like your code would be fine.