No video

Event Bus & Scriptable Object Event Channels | Unity Game Architecture Tutorial

  Рет қаралды 5,730

LlamAcademy

LlamAcademy

Күн бұрын

Пікірлер: 48
@4rcant
@4rcant 2 ай бұрын
I'm having nightmares trying to make everything "open-close", and this video just scratch that part of my brain. thank you
@halivudestevez2
@halivudestevez2 2 ай бұрын
do not get fooled by SOLID princibles. They are told to be "clean code" tools, but in real life, you just get confused. I don't mean it is completely useless, or harmful, but keep your eyes open, and ask questions if it is useful in you case, or rather makes things complicated.
@MalikenGD
@MalikenGD 2 ай бұрын
The main issue I see with this approach is the number of scriptable objects you then have to create and fill your project with, one for every single event you could need. You mention when reaching for a static class it's because you want something fast, not scalable, but I look at 100s of potential scriptable object event channels and see that is not scalable. Really surprised you went from an event bus to this, but I get the rationale, just not the solution. Good video, and great way of explaining generics. Never seen it explained that hand-holdy before, and I'm sure it helped someone stuck on the concept
@anonymous49125
@anonymous49125 2 ай бұрын
I was really skeptical clicking on this video - I'm historically not a fan of SO let alone using them for events (as that has become popular lately to do)... but right off the bat, you talk about high coupling and you explain really well that it lowers dependencies on other scripts. Very compelling when put in those terms. I'll likely still use delegates for most of this stuff (from monolithic singletons), but honestly, you make a really strong point in this video and for that I enjoyed it greatly!
@MalikenGD
@MalikenGD 2 ай бұрын
It's funny, your use case (monolithic singletons) is the exact reason we've gotten to the point where we need solutions like this.
@davidschmitt9210
@davidschmitt9210 2 ай бұрын
Great tutorial! I really liked that you offered both a code-driven approach and an inspector driven approach. The 2017 Unite talk is geared toward studios that have dedicated designers with an emphasis on inspector use. Your guide is very balanced, showing how the inspector setup is an optional step beyond what can already be done in code! Thanks so much 😁
@dreamisover9813
@dreamisover9813 2 ай бұрын
I've been using something similar - just in code without scriptable objects. But it has been really convenient for decoupled logic and avoiding logic from breaking when certain other objects don't exist in the scene
@kantagara
@kantagara 2 ай бұрын
Awesome video. I think the best one I've seen so far in regards to Event Bus being more designer friendly :D
@zivv1147
@zivv1147 2 ай бұрын
I really like your tutorials. They are of the best ones out there. I want to add a wishlist to your tutorials - that you will make a tutorial about google analytics (Firebase). That is how to to setup custom events with parameters, how to test its working, etc. I've been searching for ages and still haven't found good and up-to-date tutorials about it.
@halivudestevez2
@halivudestevez2 2 ай бұрын
I'm trying to avoid assigning events in inspectors: these assignments are easy to loose, they also fall apart if you add more parameter to the event. They are also untrackable, and hidden from the code aspects: you cannot track doen, why that event happens. I ban UnityEvent-s from my code as much as possible, and go by System.Event. More stabile.
@halivudestevez2
@halivudestevez2 2 ай бұрын
I have many criticizm about this approach, since I solodev and has negative, real-world experiences...
@LlamAcademy
@LlamAcademy 2 ай бұрын
Yup. If it doesn’t work for you and your workflow, don’t use that approach!
@sadbuttrue666
@sadbuttrue666 2 ай бұрын
@@LlamAcademy Shouldn't it be quite easy to solve the problem with the messaging approach? It would only be necessary to insert a message in the base class, which is given to each event and can be read at a suitable point. I currently use the signal system from DoozyUI and it does exactly that. Each event also has a message payload. There is then the SignalConsole and the StreamsConsole in which all fired events are displayed.
@Briezar
@Briezar 2 ай бұрын
I have the same approach as yours; if there's a Button component that needs to register click events, I'd create a reference to that Button and hookup from code instead. But then I am a programmer, I have the option to do that. It doesn't apply to designers who shouldn't be touching any codes.
@aarndal90
@aarndal90 2 ай бұрын
@@halivudestevez2 I think that's the most important point. I am totally with you. C# events are definitely the better approach to keep a better overview and not lose references. But using Unity events/event management via the Inspector also allows game designers and other disciplines in larger teams to make changes without having to intervene directly in the code, which is something you absolutely want to avoid as a game programmer ^^
@Sethizback1
@Sethizback1 2 ай бұрын
Thanks! A very helpful example of using static classes. In my project individual units had to be registered with appropriate manager classes on enable and that caused a lot of headache to manage. I will try to move most of this logic into the event bus system you've explained and hopefully adding more particle and sound effects events in the future will be much easier. The TODO list keeps growing, no matter how many refactoring passes I do...
@LlamAcademy
@LlamAcademy 2 ай бұрын
Make sure the refactoring passes are helping you deliver value to your game. Eventually "good enough" has to be good enough and move on 🙂.
@raymk
@raymk 28 күн бұрын
My problem with Event Bus is that everything can call everyone at any time. Being able to call any method through an event is super convenient and helpful for designers, however it's easy to lose track of which system should only talk to which system. If everyone can talk to anyone, there's not much incentive to keep the Enemy system only influence the enemies and not any random experience bar.
@SunSailor
@SunSailor 2 ай бұрын
If working in a bigger team, you must even expect team members, who refuse to touch prefabs, scriptableobjects or such at all.
@ragerungames
@ragerungames 2 ай бұрын
great tutorial. nice and easy to understand. thanks
@publicmmi
@publicmmi 2 ай бұрын
Like always, a great video! Thanks :)
@LlamAcademy
@LlamAcademy 2 ай бұрын
Glad you liked it 😁
@ishikindofyouknowwhat
@ishikindofyouknowwhat Ай бұрын
Very clear video, now, im starting to understand but I still wonder if story driven dialogues should be handled by events too? Like lets say a character which has different dialogue based on game advancement?
@dbweb.creative
@dbweb.creative 2 ай бұрын
Can you please make a video about saving/loading player inventory, where items are ScriptableObjects. I understand that one way to go about it is - items have to be serialized by their guid or by some sort of another id, and then maybe lookup tables or something. This way there needs to be a way to scan and add SO items to lookup table in the first place... Basically I don't know which way to go about handling this whole topic, please ponder this topic in a video, thanks.
@sealsharp
@sealsharp 2 ай бұрын
Here's my "scan for all ScriptableObjects of a type" method. public static List GetAllInstances() where T : ScriptableObject { return AssetDatabase.FindAssets($"t: {typeof(T).Name}").ToList() .Select(AssetDatabase.GUIDToAssetPath) .Select(AssetDatabase.LoadAssetAtPath) .ToList(); }
@dibaterman
@dibaterman 2 ай бұрын
Sadly Godot doesn't have static actions or delegates, in there we use signals which are really convenient in their own right. I had made an event bus and made a event system which all signals emit a object Event which contains a type String and variant data (dynamic data). This isn't too bad but in bigger projects I am thinking this isn't good. So I was thinking of going with exposing the event bus via using Resources (Scriptable Objects) and putting a signal in that. Not sure... Regardless another neat thing is a broker pattern where you can get back the other end of this system, this allows for sending lamda's to handle logic inside of a broker which works independently of the origin or even the thing using the broker. So if I have say Attack and it's 0 at base but I equip a sword with 8 attack, the attack getter simply needs to return broker and whatever identifier the parameter is subscribed with to return 8. This stacks with all modifiers and I can even get a list of all modifiers and their sources since the broker knows all XD. I recall in Unity not enjoying the event channel workflow, it made it feel like drag n drop hell.
@SebastianZoellner
@SebastianZoellner 2 ай бұрын
It is not entirely clear to me what the benefit of using a events bus is over using the standard system events.
@LlamAcademy
@LlamAcademy 2 ай бұрын
What do you mean the “standard system events”?
@joaopedromonteiro2517
@joaopedromonteiro2517 2 ай бұрын
In a real world scenario, would you use this buses only in events that connect different systems/unrelated parts of code? I do use a lot o Actions in my code, and many of those are to bind together closely related scripts, like the Player triggering some small events that are used in other scripts of the same hierarchy. In these it seems like it'd be and overkill to create all those classes.
@LlamAcademy
@LlamAcademy 2 ай бұрын
It depends on the complexity of your game. If what you have is working well and scales to the level you need it, you're good! If you find out some of those events need to be listened to by other scripts, you may consider refactoring those to a global event bus with one of these 3 methods.
@dunglevan391
@dunglevan391 2 ай бұрын
Are there any differences between Event Bus and Scriptable Object Event Channels ?
@LlamAcademy
@LlamAcademy 2 ай бұрын
Yup that’s discussed in here
@RimuruDev
@RimuruDev 2 ай бұрын
Cool
@tufanaydin6340
@tufanaydin6340 2 ай бұрын
Thanks Liaaaaaaam
@halivudestevez2
@halivudestevez2 2 ай бұрын
why SciptableObject for this? I have a MonoBehaviour for eventbus, for LevelEvents.
@LlamAcademy
@LlamAcademy 2 ай бұрын
Why do you need a MonoBehaviour for this? You do not need a GameObject nor the lifecycle methods like start/awake. 🙂 there are many ways to approach a problem. In this video I show a typical standard C# one, and two that Unity themselves have suggested in their e-book.
@kadircalloglu2848
@kadircalloglu2848 2 ай бұрын
its look like zenject event system
@Daeniak
@Daeniak 2 ай бұрын
Bread
@sealsharp
@sealsharp 2 ай бұрын
🍞
@Daeniak
@Daeniak 2 ай бұрын
@@sealsharp Bread
@franciscooteiza
@franciscooteiza 2 ай бұрын
How old are you? Maybe 30 or 35? You can't have more than 20 years of experience as a programmer.
@halivudestevez2
@halivudestevez2 2 ай бұрын
he worked overnight, too
@LlamAcademy
@LlamAcademy 2 ай бұрын
Well if we take either of those numbers 30-20 = 10. There are plenty of kids programming at 10. 35-20 = 15, people are taking boot camps at that age. I started programming in the late 90s with Visual Basic.
@Fire-Pixel
@Fire-Pixel 2 ай бұрын
FIRST :)))))
@LlamAcademy
@LlamAcademy 2 ай бұрын
😎
@halivudestevez2
@halivudestevez2 2 ай бұрын
you just overcomplicate simple things.
@halivudestevez2
@halivudestevez2 2 ай бұрын
sounds great for the first glance, but in real, it's bullshit. Bus< ??? you have to find out, look thru your 1000 code finding out what to write here. While "Bus.
Which AI Behavior Framework Should You Use? | AI Series 46
17:26
LlamAcademy
Рет қаралды 43 М.
Stream, Event Bus or Queue? What's the Difference?
12:20
James Eastham
Рет қаралды 2,5 М.
Kids' Guide to Fire Safety: Essential Lessons #shorts
00:34
Fabiosa Animated
Рет қаралды 16 МЛН
Please Help Barry Choose His Real Son
00:23
Garri Creative
Рет қаралды 23 МЛН
Gli occhiali da sole non mi hanno coperto! 😎
00:13
Senza Limiti
Рет қаралды 21 МЛН
小丑把天使丢游泳池里#short #angel #clown
00:15
Super Beauty team
Рет қаралды 47 МЛН
20 Advanced Coding Tips For Big Unity Projects
22:23
Tesseract
Рет қаралды 178 М.
Be CAREFUL with Scriptable Objects!
8:27
Code Monkey
Рет қаралды 79 М.
Developing my FIRST Game
7:46
Demanding Meow
Рет қаралды 22 М.
GOAP Enemy AI FULL IMPLEMENTATION | AI Series 50 | Unity Tutorial
1:10:13
EA Won't Let Me Play This Game - So I Hacked It
8:49
Nathan Baggs
Рет қаралды 311 М.
Better Coding in Unity With Just a Few Lines of Code
15:27
Firemind
Рет қаралды 307 М.
How To Make A Game Alone
8:11
Thomas Brush
Рет қаралды 1,1 МЛН
Event-Driven Architecture (EDA) vs Request/Response (RR)
12:00
Confluent
Рет қаралды 136 М.
Unleashing the Power of Event Channels in Unity
21:24
git-amend
Рет қаралды 9 М.
Kids' Guide to Fire Safety: Essential Lessons #shorts
00:34
Fabiosa Animated
Рет қаралды 16 МЛН