Тёмный

How to Implement Blackboard Architecture in Unity C# 

git-amend
Подписаться 12 тыс.
Просмотров 8 тыс.
50% 1

Share data easily between AI Systems, Nodes, Game Objects or Components with Blackboard architecture. Today we're building core components such as the Blackboard data store and the Arbiter-Expert paradigm. We'll navigate through the complexities of managing multiple types of data gracefully within the Blackboard framework. Additionally, we'll demonstrate how to enhance your workflow with custom editor tools, empowering you to efficiently create and manipulate Blackboard entries directly within the Unity environment. Join us as we unlock the potential of Blackboard systems for your projects!
Want to support me? 😀
Buy me a coffee! ko-fi.com/adammyhre
🔔 Subscribe for more Unity Tutorials / @git-amend
Discord: / discord
#unity3d #gamedev #indiedev
▬ Contents of this video ▬▬▬▬▬▬▬▬▬▬
0:00 Blackboard Shared Data Store
9:34 Custom Editor Tooling
19:25 Blackboard Architecture
Source code: github.com/adammyhre/Unity-Be...
Preconditions: gist.github.com/adammyhre/82d...
Service Locator Video: • Service Locator: Inver...
Assets Shown In This Video (Affiliate Links)
Dungeon Mason Tiny Hero Duo: (FREE): assetstore.unity.com/packages...
Tiny Heroes: assetstore.unity.com/packages...
Tidal Flask Dungeon Pack: assetstore.unity.com/packages...
Hierarchy Icons: assetstore.unity.com/packages...
Better Transform: assetstore.unity.com/packages...
Better Mesh Filter: assetstore.unity.com/packages...
Kyeoms VFX: assetstore.unity.com/publishe...
Follow me!
linktr.ee/gitamend

Игры

Опубликовано:

 

28 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 93   
@git-amend
@git-amend Месяц назад
Hey there, everyone! Today's topic is quite advanced, so if you're feeling a bit lost, drop any questions you have in the comments below! If you're a beginner or intermediate C# dev, take note of anything that's new to you. Use this opportunity to fill in those knowledge gaps! Let's go!
@prometheus1100
@prometheus1100 Месяц назад
Yeah I love these! They're a regular Sunday thing now for me ;)
@git-amend
@git-amend Месяц назад
Nice! Glad to hear that!
@Fitz0fury
@Fitz0fury Месяц назад
Sundays I get up with my kid and get my first watch in before he is awake enough to have TV opinions!
@SuperTungbi
@SuperTungbi Месяц назад
every time i saw a video from you, i feel my self so small, so much to learn, thank you for sharing your knowledge.
@git-amend
@git-amend Месяц назад
You are very welcome! I hope the channel is helping you in your journey to becoming an expert!
@banoulka
@banoulka Месяц назад
This channel and these videos were such a goldmine to find, hopefully the algorithm gods keep up the new engagement for you!
@git-amend
@git-amend Месяц назад
Thank you!
@DetectivePoofPoof
@DetectivePoofPoof Месяц назад
Excellent! It's great to see more advanced things instead of just the basics which are very over-represented in tutorial videos.
@git-amend
@git-amend Месяц назад
Glad you enjoyed it!
@matthewthomas1105
@matthewthomas1105 Месяц назад
I've been looking for more advanced Unity content (with explanation) so these are fantastic!
@git-amend
@git-amend Месяц назад
Glad to hear that! Welcome!
@AnotherGameDev2411
@AnotherGameDev2411 Месяц назад
I need an audiobook of you teaching me C#... Incredible topic, loved the implementation!
@git-amend
@git-amend Месяц назад
An audiobook… interesting idea! Lol. Glad you liked the vid!
@selmansavas586
@selmansavas586 Месяц назад
Always a treat, love your videos ❤️
@git-amend
@git-amend Месяц назад
Thanks so much 😊
@borailkinonu4136
@borailkinonu4136 Месяц назад
Another great video! Thank you, Adam!
@git-amend
@git-amend Месяц назад
Glad you enjoyed it! You're welcome!
@anasmostefaoui3027
@anasmostefaoui3027 Месяц назад
your videos are so valuable. Thank you for all the hard work you put to share your expertise in a friendly way. you are the best!
@git-amend
@git-amend Месяц назад
Thanks Anas, I appreciate that!
@rucesocial
@rucesocial Месяц назад
I've tried something like this before and this is a good example! Thanks
@git-amend
@git-amend Месяц назад
Nice, glad to hear that!
@sizcate
@sizcate Месяц назад
thank you so much for your content, i'm learning a lot and you are helping me achieve my first game!
@git-amend
@git-amend Месяц назад
Glad to hear it!
@NathanSL11
@NathanSL11 Месяц назад
Another great video! I usually pull out the string key into another ScriptableObject that can then cache the FNV hash at editor time instead of runtime, I usually also cast the number down to a short and then check for collisions in the editor. This is mostly for some slight bandwidth saving over the network. The benefit of the key also being a SO is it lets you reduce string naming errors across your project whether you use them as blackboard keys or any other type of named keys.
@git-amend
@git-amend Месяц назад
Great insights! Thanks for sharing that!
@SuperLordee
@SuperLordee Месяц назад
Damn dude releases one high quality video after another.
@git-amend
@git-amend Месяц назад
Thank you!
@marc8150
@marc8150 Месяц назад
Lets goooo! Another video where I‘m glad if I atleast understand half of it haha :D
@git-amend
@git-amend Месяц назад
Fantastic! Another chance to grow! Keep it up!
@marc8150
@marc8150 Месяц назад
Yes, for sure! I really appreciate the content you‘re dropping for free! You‘re great, man!
@youssefkhaled412
@youssefkhaled412 12 дней назад
Hey, Adam, just wanted to say I absolutely love the content, I hope your channel grows to the numbers you deserve! Have you considered making an advanced Unity/architecture course? I'm thinking maybe something that builds on a game like your 3D platformer, but with more fleshed out details and systems. Obviously the game itself doesn't have to be anything new (it's not a game design course after all) but something that employs different design patterns where they actually fit and make sense, not "just because." I'd definitely pay for something like that! Keep up the great work.
@git-amend
@git-amend 12 дней назад
Thanks for the kind words! I have been thinking about making a longer course about architecture actually, but it might not come until next year. I should have plenty of notes by then. In the mean time, we'll keep talking about the subject, and more about patterns and so on in smaller RU-vid chunks!
@youssefkhaled412
@youssefkhaled412 11 дней назад
@@git-amend Of course, man, that’s understandable! The quality of your content is already unbelievable as it is, good luck with everything 💪🏻
@kpm25
@kpm25 Месяц назад
awesome, the best unity coding channel on RU-vid!!
@git-amend
@git-amend Месяц назад
Made my day, thanks!
@NadjibBait
@NadjibBait Месяц назад
Great video. The Arbiter/Experts system works kinda like Utility AI. Small note: Vector3 is a struct and will be boxed when cast to an object.
@git-amend
@git-amend Месяц назад
Thanks for the comment and for noticing that. I've updated the repository to handle Vector3s without boxing! Cheers!
@TheKr0ckeR
@TheKr0ckeR Месяц назад
Thanks a lot for your effort!
@git-amend
@git-amend Месяц назад
Haha how did you comment so fast! Thank you!
@TheKr0ckeR
@TheKr0ckeR Месяц назад
@@git-amend Notifications on for your channel mate! Been waiting the video on sunday. I cant miss that.
@muhannadw
@muhannadw Месяц назад
Man, I wish I have your knowledge, keep going :]
@git-amend
@git-amend Месяц назад
I appreciate that! Glad the channel is helping you in your own journey!
@CodiushMaximush
@CodiushMaximush 20 дней назад
A very interesting video, you've found a new subscriber. My nose scrunched up a little when you had to add explicit support for each data type in the same file for your configuration scriptable object. I can't confidently come up with a better solution yet though. Also, it may be a regional thing, but I don't think that's how Arbiter is pronounced.
@git-amend
@git-amend 20 дней назад
Thanks for subscribing! Glad to have you on board!
@aurelienlerochbermuda6600
@aurelienlerochbermuda6600 Месяц назад
Thanks you !
@git-amend
@git-amend Месяц назад
No problem
@techdave99
@techdave99 Месяц назад
I think I understand the concepts. This is different from what chatgpt would have you do to implement a blackboard. Will watch again to see how it is implemented. Going to watch your other related videos again. Will definitely checkout the code for this one.
@git-amend
@git-amend Месяц назад
Sounds good. I should see what ChatGPT would say.
@techdave99
@techdave99 Месяц назад
@@git-amend it would just have you implement a basic string based system. Would much rather have an adamgpt to use. :)🤣
@git-amend
@git-amend Месяц назад
@@techdave99 Haha!
@gsggshhhh455
@gsggshhhh455 Месяц назад
Great video! Just wondering what would happen if the experts sent the same importance number to the arbiter?
@git-amend
@git-amend Месяц назад
Good question! I think the way you handle that would really depend on your game - but if you didn't do anything, it priority would go to the expert that registered first. Keep in mind too that you would probably implement much more complex values than 100/0 in the example, since you could base it on all kinds of Blackboard data as well as environment data and make it relative instead of static numbers. But it's definitely a good thing to consider.
@Fitz0fury
@Fitz0fury Месяц назад
"I'm just here to do my part to keep engagement numbers up" -sun tzu
@git-amend
@git-amend Месяц назад
And I appreciate that! Hopefully the video is also useful to you lol
@Fitz0fury
@Fitz0fury Месяц назад
@git-amend tbh I knew nothing about blackboard. seems It's a pretty cool idea. My prototype AI isn't in my main project yet. All it did was store a target porirtization array, iterate over until it hits a condition it meets, then it selects an ability based on the target. the open of the method it also has a heal curve that can interrupt the normal targeting based on party status. It's super rudimentary. I figured once I had everything else in the new core project, I'd test out other AI methods. I could see an argument for this model. It would certainly be a better model to show effective team tactics/synergy. It would also solve my hate/provoke problem, which my only solution for before was to nest the rest of the targeting logic in an isprovoked bool check. I'm just not tackling AI again until after I have the remaining core systems back in the project. Probably in 2-3 months I'll revisit to make some AI decisions. I could easily get lost having fun with coding various synergies between units with this model l. It would be pretty cool, but it could easily turn into a hole where i overengineer an AI that doesn't yield a proportional increase in game quality. It's very complex solution for a turn based rpg -but I might not feel that way after another watch and some supplemental research.
@williamfox8669
@williamfox8669 Месяц назад
I've been looking solid intermediate-skill level examples of game systems! Thank you! Something that might help make these concepts easier to grasp (across all your content) is a few more infographic breakouts to reinforce the broad (or current) concepts (like you did at 19:27). You do a great job of laying it out at the start, but I find it a bit dizzying when following the implementation for 10-15 min at a time. Stepping back to talk about what was just done and how it fits in might make your videos a bit easier to digest.
@git-amend
@git-amend Месяц назад
Thanks for the comment. The goal of this channel is to help game devs advance to a professional level; I'll keep your suggestion in mind!
@fokeyjo
@fokeyjo Месяц назад
I see this as bit of a blend of some other things I've seen, one is derived from Ryan Hipple's UniteAustin talk about scriptable objects holding a value, but of various types (but allowing them to be grouped into a single scriptable object you've definitely packed it much better). The other is that the arbiter stuff is just a utilityAI. So is blackboard just another term for utility AI? Or is it the globalised data access service, the BlackboardData stuff?
@franciscooteiza
@franciscooteiza Месяц назад
Hello Adam, Congratulations on your fantastic video! I need some advice from you. I've developed a game UI launcher and divided it into two parts for simplicity: the left panel contains links for navigation, and the right part displays the actual pages. I'm using the MVC pattern you explained in one of your previous videos, and that part is working fine. However, I need some sort of Manager to control the calls resulting from user actions. For example, when a user clicks on the 'home page' option, the system would direct to the UIManager, which receives a string indicating which page to display in the content area. I'm currently using a simple switch statement, but I feel there might be a better approach. Do you think implementing a blackboard architecture would be overkill? Or is there another architecture you would recommend like an Event-driven architecture? Plus I have some DataCacheManager to keep in memory all the games loaded from a json list, but that is another story 😄 Thank you so much for all your informative videos and the knowledge you share with us. 🥰
@git-amend
@git-amend Месяц назад
I think an event-driven architecture would be highly effective. This would allow different components of your UI to communicate via events rather than direct calls, making your system more modular and easier to maintain than a simple switch statement. Implementing a blackboard architecture might be overkill for this use case, as it's generally better suited for more complex decision-making scenarios in AI systems rather than UI navigation.
@franciscooteiza
@franciscooteiza Месяц назад
@@git-amend Thanks Adam! I highly appreciate your response.
@nullx2368
@nullx2368 Месяц назад
Im making a roguelike card game with lot of dif stats/behaviour/unknowns. I have no idea what I'll be adding and this morning i was thinking to use a blackboard for this. It's likely not the perfect solution but it should allow me to add new things faster on the fly. Awesome timing on the video, do you think this is a good usecase? In the past I'v done some extensive extendable code that allowed you to configure lot of things in editor forthe cards, but as a solo developer I felt it didnt make things faster for me..
@git-amend
@git-amend Месяц назад
Yeah, it might be a useful tool for building this kind of thing. My only word of caution is to be careful that the Blackboard does not become a god object where every different system in your game is connecting to it. It can become a real nightmare to debug if you have problems. Consider using multiple Blackboards if necessary that are specific to certain systems.
@JP-yo4zt
@JP-yo4zt 29 дней назад
Hi! I was wondering if you could make a video on implementing an inventory system similar to Witcher 3. Would really be helpful
@git-amend
@git-amend 29 дней назад
Maybe one of these days!
@myk3l9675
@myk3l9675 Месяц назад
Something something algorithm, something something engagement numbers
@git-amend
@git-amend Месяц назад
It's listening!
@damonfedorick
@damonfedorick Месяц назад
late i know, but nice.
@git-amend
@git-amend Месяц назад
Thanks!
@git-amend
@git-amend Месяц назад
@damonfedorick Can you ping me with a DM on Twitter or Discord when you get a second?
@codecombustion7878
@codecombustion7878 Месяц назад
At 23:04: var actions = blackboard.PassedActions; // is this by value? If not, then wouldn't ClearActions clear the collection? blackboard.ClearActions();
@git-amend
@git-amend Месяц назад
Thanks for pointing that out, I've updated the repository to correct that.
@AlexHosseini
@AlexHosseini 29 дней назад
Nice video! If we use an obsfucator tool to encrypt our scripts, this architecture will not work at all. any suggestions for this issue?
@git-amend
@git-amend 28 дней назад
One approach to address this issue is to use an obfuscator that supports exclusion rules. You can exclude specific types or members from obfuscation. In the case of your BlackboardKey class, you could exclude the name field from being obfuscated to ensure the ComputeFNV1aHash() function always operates on the correct data. If excluding fields from obfuscation isn't an option, you might want to reconsider how you're hashing keys. For example, instead of using a string name, you could use an identifier (like an enum or GUID) to generate your hash. This way, even if your scripts are obfuscated, your hashes should remain consistent.
@metsker4876
@metsker4876 Месяц назад
I think you've made a mistake in the Scout class. On space input you're setting value directly to the blackboard, when you should've had just toggle the dangerSensor bool. So the IExpert interface is never actually used in that case 😅 Thanks for the video though, pretty informative
@git-amend
@git-amend Месяц назад
I see what you mean, thanks for pointing that out. I'll update it in the repository later on to be correct. Thanks!
@isleeg
@isleeg Месяц назад
The hero still response on the space input, is this correct? If so then what does the scout do to impact the behaviour of the hero because it gets overruled. I used the latest code from the git
@git-amend
@git-amend Месяц назад
For the example you can remove the code from the Hero class
@Legionope
@Legionope Месяц назад
I'm having trouble with the BlackboardData's T ConvertValue() method. I'm on Unity 2019.4 and it says that Feature 'recursive patterns' is not available in C# 7.3 Please use language version 8.0 or greater. :( Any way to get that method to work somehow?
@git-amend
@git-amend Месяц назад
I'm afraid not. Support for pattern matching did not come along until just recently. With older versions of Unity you are not going to be able to avoid boxing value types using this neat trick. You can still use the Blackboard, but you don't need the ConvertValue method. Just return everything as type object and let the compiler figure it out - there will be a bit more overhead, but in many cases you probably won't notice unless you are calling it many times per frame.
@MarkRiverbank
@MarkRiverbank 19 дней назад
This is excellent, and you're teaching me many new tricks. But at 26:34 you're still directly toggling the "IsSafe" entry in the Update() method, and nothing ever sets the "dangerSensor" to true. Shouldn't your Update() code flip the value of dangerSensor [and flip it back again in Execute()] to actually use the Arbiter? Also, it looks like there's an issue with PassedActions; since it's returning a reference to the list, the ClearActions() causes the returned actions list to be cleared as well so they're never executed. The ClearActions() method probably needs to create a new empty list rather than clearing the existing one (or alternatively, the returned actions needs to be cloned from the existing list instead of a reference to it).
@git-amend
@git-amend 19 дней назад
Good observations. This was actually an oversight on my part as I rushed to complete the video. The code was updated in the repository shortly after the video was released, as another subscriber also spotted that. Please refer to the most recent commit on the repo if necessary, but it seems you already know what's been updated.
@Bluequaz
@Bluequaz Месяц назад
Love some architecture discussion in your videos Just FYI arbiter is pronounced (arr-bit-err)
@git-amend
@git-amend Месяц назад
I was wondering about that afterwards if I was pronouncing it correctly in English. We have a similar word in Norwegian.
@vidmarmarko
@vidmarmarko Месяц назад
Yeah I got confused for a moment. I thought he was saying worker in german. Great video, btw.
@user-rm2pj9jf8s
@user-rm2pj9jf8s Месяц назад
To be honest, I think you should adopt your video officially on Unity official RU-vid.. I was watching terrible types of lectures that come up on RU-vid and I fixed my code while watching your lectures.
@git-amend
@git-amend Месяц назад
Kind words, thank you.
@user-rm2pj9jf8s
@user-rm2pj9jf8s Месяц назад
@@git-amend I'm learning a lot from you.
@lyrion0815
@lyrion0815 Месяц назад
As always, great video, but one thing gets me: you only compare the BlackboardKey hashes, not their actual values. Given you use a hashing algorithm with very little collisions, you may get away with that. But if you ever get a collision, happy debugging whats going on, good luck.
@git-amend
@git-amend Месяц назад
That's a interesting point. I think though, if this were to be made more robust and still maintain efficiency, it would be better to guarantee no collisions than start comparing by value, which defeats the purpose of hashing in the first place. A different way to tackle that would be to keep a list of keys in a hashset and compare/modify the hash against that during creation, which could be done in the extension method with minimal effort. Thanks for the suggestion!
@lyrion0815
@lyrion0815 Месяц назад
@@git-amend But the only value in the BlackboardKey that is relevant for comparison, is the string name. Now string comparison is only slow, when long strings are almost equal. If they differ in the first few chars, the string comparison is fast. Even faster, if they are ReferenceEqual. I mean comparing ints is probably as performant as it can get, and each new string could just get an incrementing int Id instead of its hash, but anyways 🙂
Далее
How to Code Behaviour Trees in Unity C#
23:19
Просмотров 8 тыс.
skibidi toilet multiverse 039 (part 1)
05:29
Просмотров 3,1 млн
Recycled Car Tyres Get a Second Life! ♻️
00:58
I Built a SECRET McDonald’s In My Room!
36:00
Просмотров 14 млн
this is how my unity game looks in unreal engine 5
0:36
How to do MORE with the Observer Pattern
13:09
Просмотров 9 тыс.
ride designs that went too far 💀 #shorts
0:27
Просмотров 21 млн
Service Locator: Inversion of Control in Unity C#
19:04
Additive Async Multi-Scene Loading in Unity
16:59
Просмотров 9 тыс.
6 Code Smells REFACTORED to Patterns!
15:41
Просмотров 6 тыс.
Build a Better Finite State Machine in Unity
20:58
Просмотров 17 тыс.
УРОВЕНЬ АБСУРДА В PUBG
27:38
Просмотров 64 тыс.