Excellent tutorial i've ever seen before, doesn't like other channels that explain with many syntax that i don't know about it. But this such a perfection 👍🙏
Excellent video on the topic - i was struggling with the new input system and how to invoke the events and your explanation really brought it home for me.
Hey Peter just wanted to let you know I get so much out of your tutorials. Really like the way you explain and you cover advanced topics in a really thorough and helpful way. Thanks so much for taking the time to make all your content - wishing you all the best!
Wow I don't comment very often but this was one of the best tutorials I have ever seen for such a complex topic. I was having a really hard time reading through the documentation trying to understand these concepts and you put it together in such a perfect way that I feel like an expert coming out of this video. Thank you so much for your hard work, I'm sure you've helped many indie game devs such as myself in more ways that you can imagine!
Thanks for watching! I think I have made the video tool long - could have done better job looking from the perspective of time. Still I'm glad it has helped you! 👍
this was helpful, thanks. I wonder, instead of passing the action, could you pass a vector3 instead so you're not using Actions/Delegates? The benefit of this is you could call it from another script?
Hey! Delegates are meant to make the code more reusable. In OOP you generally pass Objects instead of an Action reference - I think that was your Vector3 question. You can call a method directly on another object like *Character* can call when dying *audioSource.Play()* . It works great but now you want to spawn particles as well, and later show *End game UI element* . While you can reference all those objects inside your *Character* class its much easier to have ex *UnityEvent OnDie* and assign all the methods to be called through the inspector. The problem that Delegates (like Action) solves is maintainability - how easy it is for you to add new features or modify existing logic in your game (and more specifically they solve the issue of "I have made my code more OOP but now how do my classes communicate with each other so that I can easily add functionality to my game"). I hope it helps!
I get the idea, but I am deeply wondering, may I missing something and I can be wrong, but using events, delegate and invoking them or using signals in zenject isnt better method?
Hey! Zenject is great as far as I can tell and surely you can inject dependencies in multiple places this way. Event driven architecture is just another way to bind a method call to something. Like when your Player was hit you want to reduce health. Instead of checking in the update "Has it changed? Has it changed? ..." constantly you create an event *HealthChanged* that will inform the UI element when the health has changed. This way Ui doesn't have to know about the Player or the player about the UI. The connection can be created dynamically at runtime. Keep in mind that in Unity the *Inspector* serves us as dependency injector. It allows artists / designers to tweak the code behind the game without knowing how to code. That is why events are so important in my opinion :)
Hey! Generally you want anonymous function only for stuff that is constant thought the scene ex Menu Button should always trigger menu visibility. To reset it the only way is to set your event Action *OnMenuPressed = null* but this resets all the callbacks assigned to this event. It is safer to use += / -= and to use a named function.
great tutorial. i love that you explain it for absolute beginners in a clear way, without expecting too much preknowledge
Glad it was helpful! 🙂
Excellent tutorial i've ever seen before, doesn't like other channels that explain with many syntax that i don't know about it. But this such a perfection 👍🙏
Glad it helped! 🙂 It isn't an easy topic to explain but I did my best to explain it as I understand it.
this actually clicked thanks to you, thanks
Great to hear that 🙂
Excellent video on the topic - i was struggling with the new input system and how to invoke the events and your explanation really brought it home for me.
Glad it was helpful! 🙂
Hey Peter just wanted to let you know I get so much out of your tutorials. Really like the way you explain and you cover advanced topics in a really thorough and helpful way. Thanks so much for taking the time to make all your content - wishing you all the best!
Great to hear! I know how hard / boring it can be to learn about programming. I am doing my best to help others to understand it :)
Wow I don't comment very often but this was one of the best tutorials I have ever seen for such a complex topic. I was having a really hard time reading through the documentation trying to understand these concepts and you put it together in such a perfect way that I feel like an expert coming out of this video. Thank you so much for your hard work, I'm sure you've helped many indie game devs such as myself in more ways that you can imagine!
Thanks for watching! I think I have made the video tool long - could have done better job looking from the perspective of time. Still I'm glad it has helped you! 👍
Your videos are great, have wanted to get into lambda expressions for a while now.
I am glad my video was helpful. I hope the explanation was ok and that you can start using the lambda expression in your code :)
wat a cool video... more new things are in this video... with great explaination...
this tutorial helped me so much.....
lots of love to your work sir ❤️❤️❤️🙏
Glad to hear that! Thanks for watching 🙂
Man your tutorials are so valuable keep the good work !
Thanks!
it is very good because even you put arguments in a lamda , one example with argumetns nad other without? very good
Glad to hear that! 👍
Great tutorial as always
Thanks for watching!
This is exactly what I needed thank you so much !
Awesome! Thanks for watching 😉
Thank you! it was a great tut to learn Csharp!! 0:54
awesome sir.
This was helpful. To next time, can you plz just go scroll up and down so I can see the whole script att the end thx :)
Thanks for the feedback!
I think this is technically an expression-bodied member. I’m still struggling with the difference tho and i remember lambda as a term more easily
It might be so. I'm not great with those technical terms.
this was helpful, thanks. I wonder, instead of passing the action, could you pass a vector3 instead so you're not using Actions/Delegates? The benefit of this is you could call it from another script?
Hey!
Delegates are meant to make the code more reusable. In OOP you generally pass Objects instead of an Action reference - I think that was your Vector3 question. You can call a method directly on another object like *Character* can call when dying *audioSource.Play()* . It works great but now you want to spawn particles as well, and later show *End game UI element* . While you can reference all those objects inside your *Character* class its much easier to have ex *UnityEvent OnDie* and assign all the methods to be called through the inspector.
The problem that Delegates (like Action) solves is maintainability - how easy it is for you to add new features or modify existing logic in your game (and more specifically they solve the issue of "I have made my code more OOP but now how do my classes communicate with each other so that I can easily add functionality to my game").
I hope it helps!
A query, we could have created a function with three params x,y,z, wouldn't it have been same as using action param in the loopthroughgrid() function?
I get the idea, but I am deeply wondering, may I missing something and I can be wrong, but using events, delegate and invoking them or using signals in zenject isnt better method?
Hey!
Zenject is great as far as I can tell and surely you can inject dependencies in multiple places this way.
Event driven architecture is just another way to bind a method call to something. Like when your Player was hit you want to reduce health. Instead of checking in the update "Has it changed? Has it changed? ..." constantly you create an event *HealthChanged* that will inform the UI element when the health has changed.
This way Ui doesn't have to know about the Player or the player about the UI. The connection can be created dynamically at runtime.
Keep in mind that in Unity the *Inspector* serves us as dependency injector. It allows artists / designers to tweak the code behind the game without knowing how to code. That is why events are so important in my opinion :)
Question: how will you remove the anonymous function then? Thank you for the tutorial and keep it up!
Hey!
Generally you want anonymous function only for stuff that is constant thought the scene ex Menu Button should always trigger menu visibility.
To reset it the only way is to set your event Action *OnMenuPressed = null* but this resets all the callbacks assigned to this event.
It is safer to use += / -= and to use a named function.
value
ty
Thanks for watching 👍
a slow motion version of codemonkey tutorials kk, thanks
Do you mean "slow" as good?
Yeah I guess I am sometimes creating similar content to Code Monkeys vids 🙂
@@SunnyValleyStudio yes. its easy to understand.
Necesito este video pero con subtitulos al español :(
When you enable subtitles you can click the COG icon and turn on auto translation and select the language that you preferer 🙂
Microsoft should remove the Lambda Expression in C#, its just stupid idea.