I appreciate how instead of just saying "avoid casting", you actually show the reason why. Everything is very well explained and thought out. As they say, it takes a smart guy to explain to someone how something works, it takes a genius to make them understand.
This video is the best explanation of interfaces I ever witnessed, you're doing a great work of presenting these concepts and making it easy to understand !
@@TheVeryMadMath Thank you so much for your kind words! Really happy to hear that my teaching style is resonating with you and that you're finding this helpful. Thanks for watching and commenting 🙏
These tutorials are wildly good cause they are great for newbies to learn the 'right' way and also good as intermediates to go back and learn the concepts better or start using them more often now that you understand the basics. Super useful.
Hey, thank you so much for your kind words! I'm really glad to hear that my explanations are helping you understand better. I appreciate your support 🙏
This might actually be one of the most important videos ever made in the history of Unreal development videos. It is the best explanation of how casting can be bad I have ever seen. Also that is a brilliant way of using Event Dispatchers. As opposed to the most common way which involves manually binding. Absolutely brilliant.
bro, let me tell you it is a TALENT to be able to take knowledge, and then structure it in a way that is understandable and teach it to students trying to understand and learn, but YOU have a gift of doing this VERY VERY well. I know you hear this a lot but seriously, this is your calling and the way you've been able to do it is just insane, and i've watched ALL your videos, this isn't just a compliment, this is a huge push for you to really devote yourself to becoming an instructor because you are insanely good at this, you may not think much of it, but look at the quality of your comments on all videos, it is nothing but the highest of praise instead of a bunch of irrelevant talk among viewers. I watch a lot of people attempt to be instructors but they all just read from a wikipedia page or straight from a source, without any type of conversion whatsoever, and because of that maybe only 40% can somewhat comprehend. but in your case you are able to do it so 100% can understand and i don't say all this lightly. Seriously, your channel has grown FAST. other tutorial channels struggle to break 10K after a few years!!! and you're already past 30k, and all this is on a channel with your name on it, instead of a catchier channel name lol! but i really hope you devote yourself to this completely, because WE WILL support you if you step up and become a full time instructor!! One of the most important and valuable professions on this planet is that of an instructor as it's a difficult job to truly grasp and you've got it in all areas!!
Hey Dom. Let me start by saying that your comment put a huge smile on my face. Your encouragement means a lot to me, and it's this kind of motivation that keeps me going and keeps the channel alive! I do wish I could make a living off of this, obviously now it's a bit far from that, but who knows what the future hold. I really appreciate your support, and I hope you enjoy the future content as well 🙏😊🙏
Finally a tutorial where the reason behind avoiding casting isn't glossed over. Always had to take that info at face value without being able to really question it. You explained it very well and concisely!
Thank you for your kind words! I'm glad to hear the explanation resonated with you. Understanding the reasoning behind things really helps with learning 🙏
You are one of the few explainig the WHYs in Unreal. Not only copy and paste stuff, but really in depth explanation of the logic behind. Thank you so much!
Very nice tutorial, as always. However, there is one things, I'd like to add. When thinking about casting: When you have to cast it is always helpful to consider which is the most simple object in the class hierachy, that serves your purpose. Example: You have a character class called "NPC" and you have a reference to it as an actor in another class. If you want to play an Animation Montage on it for example, you need to only cast to the character class to get the skeletal mesh, instead of loading in the whole "NPC"-class by casting to that one. (Note: You need a skeletal mesh to play an animation on a character)
Thank you for your insights! That's a great tip about casting to simpler objects in the class hierarchy to improve efficiency. I appreciate you taking the time to share that with the community 🙏
I am studying ACS architecture. (attach System component) and this was very useful to me because there is very little information about it. Thank you for your great contribution Eli. I know that one day it will be the ACS pattern's turn.
Your videos, this one specifically, are absolutely amazing. I think out of all the tutorials and explanations online, yours are the best. Thank you for putting this content out in the world. One of the biggest obstacles I have run into and I know many others who are learning to make games, are ways actors communicate with each other without casting to everything. I've actually watched this video a couple time to reference and do it the way you teach. Could you make a video about best practice for class dependencies and class children? This video hits that really well but myself and probably others would love for you to explain a general sense of structure for all how to organize and build out your classes. If that makes sense.
Hey, thank you so much for your kind words! I'm really glad to hear you find my videos helpful 🙏 I’ll definitely consider it for a future video. Thanks for watching and sharing your thoughts!
You know what? I started unreal some time back and at the beginning I had no idea of it and used random yt tutorials which lead to me ending up with a "ton of casting inside the event ticker". But then I found your channel and all of a sudden my game actually works and has very good performance!
Hey! I'm really glad to hear that my tutorials have helped you improve your game performance. That's what I aim for! Thank you for sharing your experience, it means a lot 🙏💪
You really are one of the best educators for Unreal. Not too much handholding but rather important information about good practices that are useful for any project. Thanks so much :)
These tutorials about design patterns for unreal are absolutely amazing, not to mention very rare on TH-cam. I’m about to follow your playslit about AI, I hope you are putting these patterns into practice there. If not, would be amazing to have a practicle series that uses all these design patterns you mention. (An inventory serie would be amazing 😊)
Hey! Thank you for the kind words and suggestions. I'm glad you're enjoying the tutorials. I definitely appreciate the idea of a practical series using these design patterns-I'll keep it in mind! An inventory series is also on my radar 😉. Thanks for being a part of the community! 🙏
Thank you so much for this video! I'm a beginner just starting to learn Blueprints, and your explanations have been incredibly helpful. You're absolutely a fantastic teacher!
Thank you for your tutorial. By the way, you can press **CTRL**, **Shift**, and **W** to adjust the font size in the UE editor, which can help you when recording tutorials.
Very clear and useful as always. Each video you make help all of us beginners. Not tested yet your chat bot as I don't need it at the moment. I think the example you use with object colliding with actor is a good one as it was one of the principal issue people had. Can't say anything than you have to keep making those videos. Pure gold, instructive, and well explained. Thanks Ali.
Hey, thank you so much for your kind words! I'm really glad to hear that you find the videos useful for beginners. Your support means a lot to me, and I’ll definitely keep them coming 🙏
This is amazing Ali. Please keep tutorials like these coming. These two concepts are essential for so many system in UE5. I’m sure there are other as well
All of your videos are amazing! You explain very important and advanced concepts in a simple and intuitive way. Great to see examples of things we should not do and why. Thank you for the amazing content!
Thank you for explaining about when casting is ok. Another way of thinking about casting. It's ok to cast to something that is always loaded to memory (player, controller, game mode etc)
Thank you for sharing your insights! That's a great way to look at it, and it definitely helps clarify when casting is safe to use. I appreciate your contribution! 🙏
Thank you for your feedback! I’m glad you found the explanation helpful. Event Dispatchers do offer great flexibility, but like I mentioned in the video. These are 2 methods that can work together, not one or the other. So always keep an eye out for opportunities to use them both
Love your videos. Would be awesome if you put together a course of making a smaller game with these best programming practices and the engines framework. Part of my problem when making a game is communicating at a larger scale. Like these videos are great and shows how to do said things, but in practice when making a full game you have many more classes communicating with one another. For example, updating UI, updating and keeping track of progression, saving that progress, etc.
Hey, thank you for your insightful comment! I appreciate your suggestion about creating a complete course. I’ll definitely consider it as I see how it could be beneficial for many. Communication between classes can be tricky, and it’s a great topic to dive into. Stay tuned! 🙏
I knew this stuff but love seeing how others explain it so hopfully i can be a better teacher too. And i think yours was super thorough and great. Also really cool about your chatbot.
Another banger. You are by far the best Unreal teacher on TH-cam (and the paid sites tbf). Hoping you eventually do some videos on GAS/ALS/Motion Matching. Keep up the great work!
Still amazes me how in depth you go.. It's almost like you are doing it for newbies.. However, you are not actually making something that can be copy/pasted.. So in order to use it, you actually have to understand it.. Just love your approach.. Best way to learn, is by understanding.. Top notch direction still.. Way better than all the "here's how you make a shooter", since thats just.. copy/paste tutorials :D
Thank you for the thoughtful comment! I'm glad you appreciate the depth of the explanations. Understanding the concepts is definitely key to mastering game development. Your support means a lot 🙏
Great video, I'm really loving your teaching style. I'd really like to see a video on effectively managing a large number of timers that are based on actual clock movement with potential multipliers. Think of a game like Factorio where there could be tens/hundreds of thousands of independent timers. I may just be overthinking it and it's not as difficult to scale as I think.
Thank you for your kind words! I'm glad you’re enjoying the content. That's an interesting suggestion, and I'll definitely add it to my list for future videos! It's a complex topic, but not impossible to tackle. Stay tuned! 🙏
I've been looking for a good explanation for this question for ages now! Thank you so much for actually explaining the differences and not just saying "do this cause it's good"
First of all, great tutorial! Diving further into memory management, would you ever make a tutorial on it in general? Or maybe a guide on soft references?
Thank you for the kind words! I'll definitely consider making a tutorial on memory management and soft references in the future. Appreciate the suggestion! 🙏
Still admiring your talent for explaining things so lucidly! I'm very interested in your opinion on the solution I came up with and how bad or good it is. I decided to switch to components, and instead of interfaces I use tags (to make sure that the actor has such a component) . For example, an AC_MyComponent component adds an “AC_MyComponent” tag to its owner and on a fordcast I can get something like GetAllActorsWithTag, then from each actor get the AC_MyComponent component and work with it. This allows me to add a component to an actor without having to change the actor. I only use interfaces instead of tags if I have to call component functions in their implementations anyway. I see these pros and cons of my solution: Pros: 1) The actor may not know anything about the component. For example, if an item can be reported by radio, we don't need to change the item itself, we just add a component. 2) The actor's logic remains as clean as possible and, as far as possible, is not cluttered by working with the component Cons: 1) I don't know, but I assume that getting actors by tag is slower than getting them by interface. Plus, you probably have to store a reference to each actor and a reference to the component from it 2) Most components will have to make an assumption about the approximate type of their owner. Extremely interested in what you think about this, what mistakes you see in it.
after watching ever tut and every vid, I'm starting to FINALLY understand UE. Thnk you so much! :) was wondering.... would it be ok to suggest your next tutorial series, or only patrons can give suggestions? more than happy to become patreon if we can give a bit of a nudge in a certain direction to learn something specific :)
Hey! I'm glad to hear that you're starting to understand UE, that's awesome! 🙏 You're more than welcome to suggest ideas for future tutorials, I always appreciate input from my viewers. Thank you for considering supporting me on Patreon as well! Just let me know what you have in mind 😊
@@AliElZoheiry im not sure if it has been already suggested, but maybe a stamina system incorporates the environment source be rly awesome! Similar to the one in BotW (how you can climb any surfaces, slide down and getting exhausted if a surface is inclined, how u go faster downhill, gliding). Even if if only for Patreons, i would gladly give u ma monei to learn smt like that. ur an amazing teacher :)
omgggggg this is so great lol im making a horror game and the code looks more terrifying than the game itself lol i am so glad i stumbled upon this im about to use these interfaces and dispatchers i KNEW there was a easier method than hard coding every single thing!
Great video. With the introduction of Unreal Engine 5, I now increasingly find myself using Gameplay Messages as a third way of writing decoupled logic between unrelated classes. This also uses the publish-subscribe model, but requires the least amount of setup in my experience and so allows for you to implement the behaviour more freely and loosely across the game. Have you had much experience with these? If so, I would love to see a video on your opinions on them and how they should best be utilised alongside interfaces and event delegates.
Hey! Thanks for your comment. I appreciate your insights on Gameplay Messages; they can indeed offer flexibility in decoupled logic. I haven't explored them in-depth yet, but I’ll add your suggestion to my list for future videos. Stay tuned! 🙏
Thanks again Ali! Glad to have you cover this topic! Great video. Quick question: At 06:00 you dragged a connecting line from Hit Actor and it placed a reroute node. Changed my life. How did you do that?
@@Tyrannyofman thanks for the response! That allows you to connect it to another node, not auto-drop a reroute node. I did my diligence on the interwebs but couldn’t find it.
@@OverlandBound I know if you do hook up a node you can double click on the string/connector and it will create a reroute node on the string itself. If you delete out the node it was connected too, your connector node will stay. I just don’t know how to drop it like he did in the graph with already connecting it to another node like a branch or function etc etc
Hey @OverlandBound, always great to hear from you ❤️ thank you for the comment Indeed, when I found this feature as well, I felt like I unlocked a super power 😅. You just press "R" when dragging a node
For a Points/Score system in the HUD, I think that would be similar to health where there's an actors component with an event dispatcher on both sides correct? I can see how an interface could be used too but It sounds like Dispatchers would be better in that case.
You're welcome! That is indeed one difference, but event dispatchers can be built in a way to operate on a global level as well, by building something called an "Event Manager". I explain that in this video here th-cam.com/video/y4fE2JdFdvY/w-d-xo.html
these videos are great, makes it really easy to understand proper design patterns and their practical applications. one question I had is whether it makes sense to use interfaces, or what the correct approach is, when the calling actor may be looking for different types of data from interface function depending on the object it's used on? ex: I have an interact interface defined and implemented similarly to the one in the video by several actors in my project. However, while my player doesn't care about what happens when it calls interact on a door, when calling it on something like a zipline, vehicle, etc. I'd like it to return a pointer/reference to the actor so my player character can do stuff with it. My initial thought would be to make it so that interact always returns an AActor pointer, but have the door return null. Then for all non-null pointers, try to cast to each class? Alternatively, maybe the player could pass a reference to itself using the interact interface, and then the actors could use that reference to pass data back to the player. For example, the player calls interact(this), then the zipline can use that pointer to set a pointer to itself in the player class like player->rideZipline(this).
Hey, thanks for your comment! You bring up a great point. Using interfaces can definitely allow for flexibility in design. Your idea of having the interact function return an `AActor` pointer sounds like a solid approach. This way, you can easily check for null and handle each actor type accordingly. Passing a reference to the player is another option that could work well, especially if you want the actors to directly communicate back with the player. Both approaches have their merits, so it really depends on what fits best in your specific use case. Good luck with your project! 🙏
This channel is gem, you deserve 1220302100123001301 times more subs. I wish i discovered you earlier, now i have to fix my code because i made a traps that can kill a player and i did them with "Cast to BP_PlayerCharacter" and then makes player go ragdoll and disable movement and player respawns, but interfaces would definitely have helped me saving memory usage. Is it possible to make it? Whenever player's body interacts with box collsion of trap it dies and simulates ragdoll physics and instead of casting all the time all types of traps to BP_PlayerCharacter it just communicates with interfaces? I will try to do that, probably i will struggle as im really new to unreal engine and new to coding lol, i just started 2/3 months ago. Anyways awesome tutorial and explanation, subbed and liked and i will watch more of ur old videos and continue watching newer ones in the future aswell. Have a nice day!
Hey! Thank you for your supportive comment! 🙏 Yes, using interfaces is a great way to streamline communication and save memory. It sounds like a solid plan to implement that for your traps! Don't worry if you face challenges; everyone starts somewhere, and learning takes time. I'm glad you found the tutorials helpful, and I appreciate you subscribing! Enjoy your journey with Unreal Engine, and have a nice day! 😊
It would be great to have more AI videos on how to add improvements and the possibility of AI tutorials that are friendly like in stores, banks for buying and selling items, etc. since there is no information on that.
As always the best tutorial maker on youtube, great video thank you ! The only thing that I still don't get is where to use an event dispatcher other than linking an Event in a Component to its owner. The receiver of an event dispatcher needs a reference to do the binding, making it less modural and lead to casting. So maybe we should avoid using event dispatchers in those cases and reserve it for when the reference is easy to get ? Or did I miss something else ?
Hey, thank you for your kind words! 🌟 You bring up a great point about event dispatchers. To take it a step further and remove the need to get a reference to the actor that is dispatching an event, you can create an "Event Manager" also known as an "Event Bus". Which will allow you to trigger an event from anywhere, and have a central listener that broadcasts it. For example, the enemy dying can trigger an event. Then the player can listen to all event of any enemy dying without having a reference to any enemy. I cover this topic in detail in this video and show how to implement it: th-cam.com/video/y4fE2JdFdvY/w-d-xo.html
Love the content, Ive been wanting to learn more about dispatchers. Is a dispatcher only used from a component, or can you use them outside of components? Thanks for the hard work!
Hey, thank you for your kind words! Dispatchers can be used both within components and outside of them. They're a great way to keep your code organized and facilitate communication between different parts of your game. If you have more questions, feel free to ask! 🙏
When you use "Get Actor of Class" or "Get Component by Class" in an attempt to get the actor that is calling the dispatcher, so that you can bind the dispatcher, can this have negative effects for other actors that have different logic but use the same component or class? Let's say that it does cause issues, I've heard that you can also use tags to get specific actors, or storing references to actors in game instances, would these be more preferable or the same? Thanks!
Hi, love your videos, keep up the great work. I would like to ask for a video which I was not able to find anywhere or at least not explained video how it works really. The subject is control rig blueprint. How to control the players character during game- to grab a door handle when opening a door, make character touch a wall in front when moving too close or simular stuff. I followed some tutorials but they never explain how the transforms changes work and I see alot of weird position of arms or legs of which I am sure should not be possible. Thank you.
Hey! Thanks so much for your kind words and your suggestion. Controlling character interactions like that sounds interesting, and I'll definitely consider it for a future video. The way transforms work can be tricky, but I’ll try to clarify that. Appreciate your support! 🙏
Hey, thank you for the question! It's generally a good idea to use multiple interfaces when you have distinct behaviors or functionalities that may not always be applicable to every class. This keeps your code cleaner, easier to maintain, and more modular. Hope that helps! 🙏
Thanks Ali! The way you explain different concepts is so clear. you really have a talent for this. I have one question though. All of the videos I have watched regarding interfaces, references, and memory usage always use the same example: an interactable interface and an interact function / event. This is great and all but what if I only want to get basic data of an object, like world transform for example, from another object, let's say my player character, without creating a hard reference to that specific object. Is it possible to use BP interfaces for that? I was thinking of creating a generic BP interface called "reference manager" where I would create functions that declare basic data so I could get them and create variables out of them inside the objects that need a reference to this data.
Hey! Thank you for your kind words, I really appreciate it 🙏 For getting basic information, you should already be able to do that on any actor, you can get the transform of any actor without having a reference to a specific class. So I wouldn't recommend creating an interface for defining functions that might already exist on the actor class.
@@AliElZoheiry Thanks for replying! I'm not sure how it's possible to get an actor's data from another actor's blueprint without creating a hard reference though. let's say I use the "get actor rotation" node in my player character blueprint and the target is another actor called BP_Box for example. I'm not sure how I can do that without declaring to my BP_PlayerCharacter that BP_Box exists. I know that casting creates a hard reference so I was trying to find a way to easily get basic data from actor to actor without having to create hard references. In the meantime I found a workaround using a blueprint interfaces and tags which seems to work relatively well
Good explanation! One thing which i always struggling is...when you doesn't have reference to actor for interface/dispatcher call. In your example it's pretty easy with trace, but imagine case when door actor should ask some global manager actor, can open? (Like when alarm state is active or something). Or manager has to tell all objects to change their states... In that case door/manager should has hard reference on begin play or hard referenced through level. And i don't have another solution for that, and i really bothered of that because most of the "managers" has many hard references to deal with other things in game.
Hey! Great question, and I'm glad you found the explanation useful 🙏 For managing references like this, all actors can have a hard reference to the "manager" actor itself, that's fine because you expect that actor to always be there and all other actors to depend on it (since it's a global manager), but don't put references to other actors in the manager itself, the manager should be agnostic of other classes. I have a tutorial on how to build an "Event manager" for usecases like that, check it out if you're interested th-cam.com/video/y4fE2JdFdvY/w-d-xo.html
Thanks for the compliment! Besides health, I often use Components like Movement, Inventory, and many others, though it highly depends on the type of game. If you have any specific use cases in mind, feel free to ask! 🙏
@@AliElZoheiry Thank YOU! Since you asked....! I'm building a single-player, turn based battle + explore game inspired by PS1 final fantasies. For battle mode - Health as you suggested, I suppose MP for magic abilities. For explore mode - Inventory as you suggested would be great. So long as the items are unique to explore mode (e.g. keys). Any other ideas at top of mind?
Hey love ur tutorial im been using ue damage system from a few week ago but i really want to learn jow to make upgrade and upgrade item pick up like risk of rain like armor ,speed , ability,bla bla..... cause so far only ur tutorial work hope u can help also keep going man ur tutorial is amazing
Ali your videos are wonderful. I have watched almost all of them, and over the last few weeks I have used a lot of the info for building a basic FPS. However, I've got myself a bit confused. Through your tutorials, I have BPI_Damageable set up, and the Health component set up. This has resulted in a Death custom event and an On_death event in my player character blueprint, and I am not sure which to use. When it comes to these systems, I am confused on which should be integrated with my HUD. Is it better to have the interface pass damage info to the component which then passes the damage to the player character and then the health bar? I am confused enough that I don't know if I am even explaining this properly.
Hey! Thank you for the kind words, I'm really glad to hear that my videos have been helpful for your FPS project 🙏 As for your question, like I said in the video, there is no right or wrong, or one way that's better than the other, you should be using both approaches, and assess which approach is right for your specific use case. I suggest using the information from this video to try to understand which one is better for your specific need.
What is your preferable option for player/UI communication and why? Right now i use interfaces, because my player doesnt have references to all UI elements, only its parent and i also need to pass data from them, but i dont know if this is the best method.
Hey! Interfaces are a solid choice for decoupling your player from UI elements. They provide flexibility since you don’t need direct references. but event dispatchers are useful to notify the UI element that something has happened, like the example I mentioned with decreasing the health percentage on the widget when the player takes damage. So feel free to use both, there is no one size fits all solution
Comment after comment straight gushing over this guy's ability to teach. I keep scrolling and they're all saying the same thing using different words. Going to give this a watch and see if it's legit or if guy just rented some bots to flood the comment section.
Fuk... yeah, that was very well constructed and extremely informative compared to the majority of UE content out here. Sorry for doubting. Keep on l, keeping on.
Hey! I appreciate your skepticism-it’s always good to question things. I genuinely strive to educate and not just entertain, I believe that's what the comments are reflecting because there's a lot of content out there focused on getting views only and the content is secondary. I leave a lot of views on the table to cater for those who actually want to learn 🙏
Hello Ali, how are you? I have a question that when I use the animation layer interface, I have to use float variables to communicate the variables in the VR animation blueprint, but I want to use the enum variable to communicate the variables. I asked several people and they said that you can't use enum for communication, because then you can't define the list of variables defined in enum separately, and that variable will actually be unused. What do you think? If we understand, can I ask my question with a picture in discord?
Hey! I'm doing well, thanks for asking. 😊 Not sure what you mean by "can't use enums for communication", enums are basically just an array of integers under the hood, you can use them as you use any variable. I don't see any problem with that
Hi! I really like your video! Could you please make a video about data assets and best way to create content for project? Because for now I could use data assets, data tables, raw blueprints for some data and etc. I want to understand, when I should use every stuff, thank you!
Hey! I'm glad you liked the video! Thanks for the suggestion, that's a great topic. I'll definitely consider making a video on data assets and when to use each type. Stay tuned! 🙏
Ali there is a Project i wish you work on A game like Conquer online Topdown with all its features and add the Ai Series on top of it this will be Massive 😊
Hello and thank you for this great video! I really like your work and your voice 😊. Do you think it’s a good idea to add some Cast To (player controller, game mode, etc.) in the Game Instance, promote it to a variable, and load it during the Loading Page to use it whenever needed without using more resources? Thank you very much.
Hey! Thank you for your kind words 😊 It's definitely a good idea to cast to your custom framework classes and store references for those. It has no impact on memory since these classes are always loaded into memory anyway, so don't worry about casting or storing references to them
Hi, thank you for the tutorials, I have been watching your videos for a while. I have a design question, I want to make a simulation game in UE5, but I don't know where to start. There's barely any information about it online. The goal is, NPC simulating, doing stuff, having their own schedule and conflict, interacting with each other, even the player is not around, make them have their own persistence. It's kinda like a backend simulation, do you have any tips on how to achieve something like this? If you need example, something like what X4: foundations did on their simulation, but in UE5.
Hey! Thanks for your support and for watching my videos 🙏 For a simulation game with persistent NPCs, I'd recommend starting by breaking down your design into smaller systems. Focus on creating an NPC behavior manager to define how they interact, their schedules, and conflicts. Implementing a state machine can help manage their behaviors effectively. You might also want to look into using data structures to store NPC states and schedules, enabling them to function independently. It's a complex project, but breaking it down can make it more manageable. Good luck
@@AliElZoheiry Thank you so much, I'll try get started looking into these things and study them. Thanks for pointing me out in the right direction. I really needed this one. I'm kinda at a loss.
So if you wanted your player to be able to push a button to open a door, there would be an interface implemented between the player and the button, and an event dispatch between the button and the door?
Well it depends on a lot of things, but generally speaking, if you have multiple different kinds of doors, all with their own unique "Open" function. Then yes, you would have a door interface, and the player just calls an "Open" function on that door reference without caring what type of door it is. Then if you want the door to notify the player when it's fully open, you can then indeed dispatch an event from the door saying where the player listens to it, and then knows it's fully open when it's called
Hey! If you have different actor components on your actor, you can definitely have them communicate together, as long as they first check if the other component is valid or not, so that they don't make the assumption that it will always be there
Tbh, I'm still confused about what the difference is? You can call an Event dispatcher or an interface, and you will get the same result + without casting, the only difference I can see is that Event dispatchers can't have a function like interfaces, but they are the same with Events. 18:40 What did you mean by "Makes an assumption....and doesn't allow you to make anything else, can't extend it" can you give an example? BTW you are underrated, thanks for all the hard work, been enjoying your videos recently
While Event Dispatchers can be used to trigger events, they don't provide the same level of flexibility as interfaces. Interfaces allow you to define the exact behavior that implementing classes must follow, ensuring consistency and modularity. Event Dispatchers, on the other hand, simply broadcast events without enforcing any specific behavior. For example: You would Event Dispatch a change to an attribute, like Health and have an Interface for the TakeDamage. The TakeDamage interface would be sent to the actor when it is hit. If the actor implements the interface TakeDamage, it would react accordingly (for this example, let's say it reduces its health on its StatsComponent.) The actor sends the function of ChangeHealth to the StatsComponent to change the Health variable. Once the variable has been changed, the StatsComponent then broadcasts (Call) the OnHealthChanged dispatch. The health UI (User Interface) is setup to listen for any broadcasts when the OnHealthChanged Event Dispatcher is called out (Bind). It then changes the UI to reflect the current Health status. As a bonus, your weapon is also listening for the OnHealthChanged dispatch, and when it receives the message, it begins to glow brighter and brighter the lower your health gets. Both of those happen at the same time. The main difference is that the TakeDamage had to be sent to the actor, otherwise it does nothing at all. The OnHealthChanged is announced and just works.
Think of a scenario where you have a commander NPC on your team that provides a stat boost to all allied troops. When the commander dies, it could fire off an event that would trigger each individual troop NPC to receive that event and act on it. In fact, the troops could use an Interface on what to do with that event, fighters atk drops, mages spellpower drops, etc. If you just use interfaces, you would need to cycle all of your NPCs to run the Interface function. Also, where would you initiate this loop? In the commander death routine? That increases the coupling between the commander and troops. Event dispatchers allow objects to communicate a specific event to other objects then let them handle it independently. Interfaces allow different objects to handle events uniquely based on their specific characteristics. Least that was my take away.
@@MarekGamer76 "That increases the coupling between the commander and troops." aha ok, thats what I wanted to hear + it would be easier to Call and Bind than implementing Interface on all actors, Thx .
Consider I would have a pickable item in my game and I also have an Inventory Component for my Character. Is it feasible to update my Inventory Component (Like number of bandages) using event dispatchers ? I mean after I've picked up something(a bandage :) ) I call a dispatcher to update my inventory. Thanks :)
Hey! Yes, using event dispatchers to update your Inventory Component when picking up items is definitely a feasible approach. It’s a clean way to decouple the pickup logic from the inventory management. Just make sure your dispatcher is set up properly to handle those updates. Hope that helps! 😉
I appreciate how instead of just saying "avoid casting", you actually show the reason why. Everything is very well explained and thought out.
As they say, it takes a smart guy to explain to someone how something works, it takes a genius to make them understand.
Thank you so much for your kind words! I'm glad to hear you found the explanations clear and helpful. It means a lot to me 🙏
This video is the best explanation of interfaces I ever witnessed, you're doing a great work of presenting these concepts and making it easy to understand !
@@TheVeryMadMath Thank you so much for your kind words! Really happy to hear that my teaching style is resonating with you and that you're finding this helpful. Thanks for watching and commenting 🙏
These tutorials are wildly good cause they are great for newbies to learn the 'right' way and also good as intermediates to go back and learn the concepts better or start using them more often now that you understand the basics. Super useful.
dude plz dont stop u explain shit step by step, u actually made me understand so much shit i was strugglin with...keep it up like this
Hey, thank you so much for your kind words! I'm really glad to hear that my explanations are helping you understand better. I appreciate your support 🙏
I absolutely love that you are teaching exactly at my level: Not too cuddly, but also not assuming I write C++ all day. Absolutely. Fantastic. Work.
Thank you so much for your kind words! I'm glad to hear the content resonates with you. I appreciate your support 🙏
This might actually be one of the most important videos ever made in the history of Unreal development videos. It is the best explanation of how casting can be bad I have ever seen. Also that is a brilliant way of using Event Dispatchers. As opposed to the most common way which involves manually binding. Absolutely brilliant.
Thank you for your kind words! I'm really glad you found the video helpful and enjoyed the explanation. Your support means a lot 🙏
bro, let me tell you it is a TALENT to be able to take knowledge, and then structure it in a way that is understandable and teach it to students trying to understand and learn, but YOU have a gift of doing this VERY VERY well. I know you hear this a lot but seriously, this is your calling and the way you've been able to do it is just insane, and i've watched ALL your videos, this isn't just a compliment, this is a huge push for you to really devote yourself to becoming an instructor because you are insanely good at this, you may not think much of it, but look at the quality of your comments on all videos, it is nothing but the highest of praise instead of a bunch of irrelevant talk among viewers. I watch a lot of people attempt to be instructors but they all just read from a wikipedia page or straight from a source, without any type of conversion whatsoever, and because of that maybe only 40% can somewhat comprehend. but in your case you are able to do it so 100% can understand and i don't say all this lightly.
Seriously, your channel has grown FAST. other tutorial channels struggle to break 10K after a few years!!! and you're already past 30k, and all this is on a channel with your name on it, instead of a catchier channel name lol! but i really hope you devote yourself to this completely, because WE WILL support you if you step up and become a full time instructor!! One of the most important and valuable professions on this planet is that of an instructor as it's a difficult job to truly grasp and you've got it in all areas!!
Hey Dom. Let me start by saying that your comment put a huge smile on my face. Your encouragement means a lot to me, and it's this kind of motivation that keeps me going and keeps the channel alive! I do wish I could make a living off of this, obviously now it's a bit far from that, but who knows what the future hold.
I really appreciate your support, and I hope you enjoy the future content as well 🙏😊🙏
Finally a tutorial where the reason behind avoiding casting isn't glossed over. Always had to take that info at face value without being able to really question it. You explained it very well and concisely!
Thank you for your kind words! I'm glad to hear the explanation resonated with you. Understanding the reasoning behind things really helps with learning 🙏
You are one of the few explainig the WHYs in Unreal. Not only copy and paste stuff, but really in depth explanation of the logic behind. Thank you so much!
Thank you for your kind words! I'm glad to hear you appreciate the explanations. Understanding the "why" is essential, and I aim to make it clear 🙏
Very nice tutorial, as always. However, there is one things, I'd like to add.
When thinking about casting:
When you have to cast it is always helpful to consider which is the most simple object in the class hierachy, that serves your purpose.
Example:
You have a character class called "NPC" and you have a reference to it as an actor in another class. If you want to play an Animation Montage on it for example, you need to only cast to the character class to get the skeletal mesh, instead of loading in the whole "NPC"-class by casting to that one.
(Note: You need a skeletal mesh to play an animation on a character)
Thank you for your insights! That's a great tip about casting to simpler objects in the class hierarchy to improve efficiency. I appreciate you taking the time to share that with the community 🙏
I am studying ACS architecture.
(attach System component) and this was very useful to me because there is very little information about it.
Thank you for your great contribution Eli.
I know that one day it will be the ACS pattern's turn.
Your videos, this one specifically, are absolutely amazing. I think out of all the tutorials and explanations online, yours are the best. Thank you for putting this content out in the world.
One of the biggest obstacles I have run into and I know many others who are learning to make games, are ways actors communicate with each other without casting to everything. I've actually watched this video a couple time to reference and do it the way you teach.
Could you make a video about best practice for class dependencies and class children? This video hits that really well but myself and probably others would love for you to explain a general sense of structure for all how to organize and build out your classes. If that makes sense.
Hey, thank you so much for your kind words! I'm really glad to hear you find my videos helpful 🙏 I’ll definitely consider it for a future video. Thanks for watching and sharing your thoughts!
You know what? I started unreal some time back and at the beginning I had no idea of it and used random yt tutorials which lead to me ending up with a "ton of casting inside the event ticker". But then I found your channel and all of a sudden my game actually works and has very good performance!
Hey! I'm really glad to hear that my tutorials have helped you improve your game performance. That's what I aim for! Thank you for sharing your experience, it means a lot 🙏💪
You really are one of the best educators for Unreal. Not too much handholding but rather important information about good practices that are useful for any project. Thanks so much :)
Thank you! I really appreciate your kind words. I'm glad to hear you find the information helpful 🙏
These tutorials about design patterns for unreal are absolutely amazing, not to mention very rare on TH-cam. I’m about to follow your playslit about AI, I hope you are putting these patterns into practice there. If not, would be amazing to have a practicle series that uses all these design patterns you mention. (An inventory serie would be amazing 😊)
Hey! Thank you for the kind words and suggestions. I'm glad you're enjoying the tutorials. I definitely appreciate the idea of a practical series using these design patterns-I'll keep it in mind! An inventory series is also on my radar 😉. Thanks for being a part of the community! 🙏
I never really understood event dispatchers before, thank you so much for making this amazing tutorial!!!! God bless!!!
You're very welcome! I'm glad the tutorial helped clarify event dispatchers for you. Thank you for watching and commenting 🙏
Thank you so much for this video! I'm a beginner just starting to learn Blueprints, and your explanations have been incredibly helpful. You're absolutely a fantastic teacher!
You're very welcome! I'm glad to hear that you found the explanations helpful. Thank you for your kind words, and happy learning! 🙏
As usual, your video is super clear and answer the very question I was asking myself.. It is very helpfull to have you on TH-cam !
Thank you for your tutorial. By the way, you can press **CTRL**, **Shift**, and **W** to adjust the font size in the UE editor, which can help you when recording tutorials.
Thank you for the tip! That's really helpful 🙏 I'll definitely keep it in mind for future recordings!
Very clear and useful as always. Each video you make help all of us beginners. Not tested yet your chat bot as I don't need it at the moment. I think the example you use with object colliding with actor is a good one as it was one of the principal issue people had. Can't say anything than you have to keep making those videos. Pure gold, instructive, and well explained. Thanks Ali.
Hey, thank you so much for your kind words! I'm really glad to hear that you find the videos useful for beginners. Your support means a lot to me, and I’ll definitely keep them coming 🙏
This is amazing Ali. Please keep tutorials like these coming. These two concepts are essential for so many system in UE5. I’m sure there are other as well
Thank you so much for your comment! I'm glad you found it useful. I'll definitely keep creating more tutorials around essential concepts in UE5 🙏
All of your videos are amazing! You explain very important and advanced concepts in a simple and intuitive way. Great to see examples of things we should not do and why. Thank you for the amazing content!
Thank you so much for your kind words! I'm really glad to hear that you find my explanations helpful and intuitive. I appreciate your support 🙏
Thank you for explaining about when casting is ok.
Another way of thinking about casting. It's ok to cast to something that is always loaded to memory (player, controller, game mode etc)
Thank you for sharing your insights! That's a great way to look at it, and it definitely helps clarify when casting is safe to use. I appreciate your contribution! 🙏
The best explanation I ever saw regarding the 2 options. I prefer Event Dispatcher for the flexibility and seems easier to understand.
Thank you for your feedback! I’m glad you found the explanation helpful. Event Dispatchers do offer great flexibility, but like I mentioned in the video. These are 2 methods that can work together, not one or the other. So always keep an eye out for opportunities to use them both
Love your videos. Would be awesome if you put together a course of making a smaller game with these best programming practices and the engines framework. Part of my problem when making a game is communicating at a larger scale. Like these videos are great and shows how to do said things, but in practice when making a full game you have many more classes communicating with one another. For example, updating UI, updating and keeping track of progression, saving that progress, etc.
Hey, thank you for your insightful comment! I appreciate your suggestion about creating a complete course. I’ll definitely consider it as I see how it could be beneficial for many. Communication between classes can be tricky, and it’s a great topic to dive into. Stay tuned! 🙏
Best tutorial on youtube, please keep doing tutorials like this
Thank you so much for your kind words! I'm glad you found it helpful. I'll definitely keep making more tutorials 🙏
I knew this stuff but love seeing how others explain it so hopfully i can be a better teacher too. And i think yours was super thorough and great. Also really cool about your chatbot.
Thank you for your kind words! I'm glad you found my explanation helpful. It's always great to share knowledge and learn from each other 🙏
Another banger. You are by far the best Unreal teacher on TH-cam (and the paid sites tbf). Hoping you eventually do some videos on GAS/ALS/Motion Matching. Keep up the great work!
Thank you for the kind words! I really appreciate your support 🙏 I'll definitely keep those topics in mind for future videos.
Thanks for clarifying the casting taboo.
You're welcome! Glad I could help clarify that 🙏
Clean and clear, as usual. Thanks Ali
Hey @@Pizatol good to see you again! Thanks for the comment, glad you found it used 🙏😊
This was exactly what I needed. I should share this video with my classmates!
I'm glad to hear it was helpful! Feel free to share it with your classmates 🙏 Thank you for watching!
Still amazes me how in depth you go.. It's almost like you are doing it for newbies.. However, you are not actually making something that can be copy/pasted.. So in order to use it, you actually have to understand it..
Just love your approach.. Best way to learn, is by understanding.. Top notch direction still.. Way better than all the "here's how you make a shooter", since thats just.. copy/paste tutorials :D
Thank you for the thoughtful comment! I'm glad you appreciate the depth of the explanations. Understanding the concepts is definitely key to mastering game development. Your support means a lot 🙏
well i watched around 5 or 6 of your videos and i can say that you are a legend (subscribed from first video )
شكرا لك علي الزهيري , بارك الله فيك
Thank you so much for your kind words! I'm really glad you enjoyed the videos and found them helpful. Appreciate the support! 🙏
I really do like your tutorials as you really do explain things very well. I am hoping you cover the Command design pattern at some point.
Hey! Thank you for your kind words, I appreciate it! I'll definitely consider covering the Command design pattern in future content 🙏
This is by far the best explination for event dispatchers as Unreal's docs doesn't explain them well.
Thank you for your kind words! I’m glad you found my explanation helpful 🙏
Best explanation best tutorial best developer and the god use of ue5. You deserve 1 mil subscribers
Thank you so much for your kind words! I really appreciate your support 🙏 Glad you found the tutorial helpful!
Great video, I'm really loving your teaching style. I'd really like to see a video on effectively managing a large number of timers that are based on actual clock movement with potential multipliers. Think of a game like Factorio where there could be tens/hundreds of thousands of independent timers. I may just be overthinking it and it's not as difficult to scale as I think.
Thank you for your kind words! I'm glad you’re enjoying the content. That's an interesting suggestion, and I'll definitely add it to my list for future videos! It's a complex topic, but not impossible to tackle. Stay tuned! 🙏
Excellent explanation man. Lovin the content lately!
Thank you! I'm glad you're enjoying the content 🙏
Another banger. So glad I found this channel.
Thanks for your support! I'm really glad you're enjoying the content 🙏
I've been looking for a good explanation for this question for ages now! Thank you so much for actually explaining the differences and not just saying "do this cause it's good"
You're very welcome! I'm glad the explanation was helpful. Thank you for your comment 🙏
Great video explaining the differences. Super helpful!
Thank you! I'm glad you found it helpful 🙏
First of all, great tutorial!
Diving further into memory management, would you ever make a tutorial on it in general? Or maybe a guide on soft references?
Thank you for the kind words! I'll definitely consider making a tutorial on memory management and soft references in the future. Appreciate the suggestion! 🙏
Still admiring your talent for explaining things so lucidly!
I'm very interested in your opinion on the solution I came up with and how bad or good it is. I decided to switch to components, and instead of interfaces I use tags (to make sure that the actor has such a component) . For example, an AC_MyComponent component adds an “AC_MyComponent” tag to its owner and on a fordcast I can get something like GetAllActorsWithTag, then from each actor get the AC_MyComponent component and work with it. This allows me to add a component to an actor without having to change the actor. I only use interfaces instead of tags if I have to call component functions in their implementations anyway. I see these pros and cons of my solution:
Pros:
1) The actor may not know anything about the component. For example, if an item can be reported by radio, we don't need to change the item itself, we just add a component.
2) The actor's logic remains as clean as possible and, as far as possible, is not cluttered by working with the component
Cons:
1) I don't know, but I assume that getting actors by tag is slower than getting them by interface. Plus, you probably have to store a reference to each actor and a reference to the component from it
2) Most components will have to make an assumption about the approximate type of their owner.
Extremely interested in what you think about this, what mistakes you see in it.
Amazing, thank you for this
Keep it up !
You're very welcome! Thanks for your kind words, I always love reading your comments. I appreciate it 🙏
The unreal master is back! ❤ Thanks for that perfect explanation!
Thank you for your kind words! I'm glad you found the explanation helpful 🙏
after watching ever tut and every vid, I'm starting to FINALLY understand UE. Thnk you so much! :)
was wondering.... would it be ok to suggest your next tutorial series, or only patrons can give suggestions? more than happy to become patreon if we can give a bit of a nudge in a certain direction to learn something specific :)
Hey! I'm glad to hear that you're starting to understand UE, that's awesome! 🙏 You're more than welcome to suggest ideas for future tutorials, I always appreciate input from my viewers. Thank you for considering supporting me on Patreon as well! Just let me know what you have in mind 😊
@@AliElZoheiry im not sure if it has been already suggested, but maybe a stamina system incorporates the environment source be rly awesome! Similar to the one in BotW (how you can climb any surfaces, slide down and getting exhausted if a surface is inclined, how u go faster downhill, gliding).
Even if if only for Patreons, i would gladly give u ma monei to learn smt like that. ur an amazing teacher :)
Ahh I like it for my "Games Dissected" series, I'll definitely keep it in mind 👍@@Tenchinu
@@AliElZoheiry thnk u very much! cannot wait :)
nice always wanted know about event dispatcher properly. :DD nice video as always ty
You're very welcome! I'm glad you found it helpful 🙏 Thanks for watching and commenting!
Can you make a course about everything the most used nodes in blueprints? That would be very helpful for a lot of people I believe. Great videos btw!!
Hey! Thank you for the suggestion! I’ll definitely consider making a course on the most used nodes in Blueprints 🙏 Glad you’re enjoying the videos!
omgggggg this is so great lol im making a horror game and the code looks more terrifying than the game itself lol i am so glad i stumbled upon this im about to use these interfaces and dispatchers i KNEW there was a easier method than hard coding every single thing!
I'm glad you found it useful for your horror game! Interfaces and dispatchers can definitely simplify things. Good luck with your project! 😄
Thank you for yet another amazing and free lession
You're very welcome! I'm glad you found it helpful. Thank you for watching and commenting 🙏
Great explanation.. Thank you Ali ❤
You're very welcome! I’m glad you found it helpful. Thank you for watching and commenting! ❤️
Great video. With the introduction of Unreal Engine 5, I now increasingly find myself using Gameplay Messages as a third way of writing decoupled logic between unrelated classes. This also uses the publish-subscribe model, but requires the least amount of setup in my experience and so allows for you to implement the behaviour more freely and loosely across the game. Have you had much experience with these? If so, I would love to see a video on your opinions on them and how they should best be utilised alongside interfaces and event delegates.
Hey! Thanks for your comment. I appreciate your insights on Gameplay Messages; they can indeed offer flexibility in decoupled logic. I haven't explored them in-depth yet, but I’ll add your suggestion to my list for future videos. Stay tuned! 🙏
Beat Boxing vid next? ;) Great explanation as always and very much appreciated for sharing. ~Thank you.
@@KINGDOMSONSTV hahaha glad you noticed that Easter egg, now I know who watches till the end ;)
Thanks again Ali! Glad to have you cover this topic! Great video. Quick question: At 06:00 you dragged a connecting line from Hit Actor and it placed a reroute node. Changed my life. How did you do that?
Think you just hold ctrl while dragging. I could be wrong tho. Not at my PC atm
@@Tyrannyofman thanks for the response! That allows you to connect it to another node, not auto-drop a reroute node. I did my diligence on the interwebs but couldn’t find it.
@@OverlandBound I know if you do hook up a node you can double click on the string/connector and it will create a reroute node on the string itself. If you delete out the node it was connected too, your connector node will stay. I just don’t know how to drop it like he did in the graph with already connecting it to another node like a branch or function etc etc
Hey @OverlandBound, always great to hear from you ❤️ thank you for the comment
Indeed, when I found this feature as well, I felt like I unlocked a super power 😅. You just press "R" when dragging a node
lol I literally was thinking this question the other day. You mind reader! Great video thank you.
For a Points/Score system in the HUD, I think that would be similar to health where there's an actors component with an event dispatcher on both sides correct? I can see how an interface could be used too but It sounds like Dispatchers would be better in that case.
Haha, that's funny! I'm glad the video resonated with you. Thank you for watching and your kind words! 😊
Just use both. They work very wonderfully when use together
Thanks for the input! It's great to hear that they work well together. Appreciate your comment! 🙏
That is, it turns out that the interfaces operate at the global level and the event dispatcher locally, Thank you very much
You're welcome! That is indeed one difference, but event dispatchers can be built in a way to operate on a global level as well, by building something called an "Event Manager". I explain that in this video here th-cam.com/video/y4fE2JdFdvY/w-d-xo.html
these videos are great, makes it really easy to understand proper design patterns and their practical applications. one question I had is whether it makes sense to use interfaces, or what the correct approach is, when the calling actor may be looking for different types of data from interface function depending on the object it's used on?
ex: I have an interact interface defined and implemented similarly to the one in the video by several actors in my project. However, while my player doesn't care about what happens when it calls interact on a door, when calling it on something like a zipline, vehicle, etc. I'd like it to return a pointer/reference to the actor so my player character can do stuff with it. My initial thought would be to make it so that interact always returns an AActor pointer, but have the door return null. Then for all non-null pointers, try to cast to each class?
Alternatively, maybe the player could pass a reference to itself using the interact interface, and then the actors could use that reference to pass data back to the player. For example, the player calls interact(this), then the zipline can use that pointer to set a pointer to itself in the player class like player->rideZipline(this).
Hey, thanks for your comment! You bring up a great point. Using interfaces can definitely allow for flexibility in design. Your idea of having the interact function return an `AActor` pointer sounds like a solid approach. This way, you can easily check for null and handle each actor type accordingly. Passing a reference to the player is another option that could work well, especially if you want the actors to directly communicate back with the player. Both approaches have their merits, so it really depends on what fits best in your specific use case. Good luck with your project! 🙏
This channel is gem, you deserve 1220302100123001301 times more subs. I wish i discovered you earlier, now i have to fix my code because i made a traps that can kill a player and i did them with "Cast to BP_PlayerCharacter" and then makes player go ragdoll and disable movement and player respawns, but interfaces would definitely have helped me saving memory usage. Is it possible to make it? Whenever player's body interacts with box collsion of trap it dies and simulates ragdoll physics and instead of casting all the time all types of traps to BP_PlayerCharacter it just communicates with interfaces? I will try to do that, probably i will struggle as im really new to unreal engine and new to coding lol, i just started 2/3 months ago. Anyways awesome tutorial and explanation, subbed and liked and i will watch more of ur old videos and continue watching newer ones in the future aswell. Have a nice day!
oh i just watched further and i know that i should use event dispatchers instead of interfaces when it comes to player's death i guess XD
Hey! Thank you for your supportive comment! 🙏 Yes, using interfaces is a great way to streamline communication and save memory. It sounds like a solid plan to implement that for your traps! Don't worry if you face challenges; everyone starts somewhere, and learning takes time. I'm glad you found the tutorials helpful, and I appreciate you subscribing! Enjoy your journey with Unreal Engine, and have a nice day! 😊
@@AliElZoheiry thanks Ali, keep it up with ur great content if u ever release course im 100% buying it. Have a nice day aswell
Найкраще пояснення цієї теми на TH-cam
Дякую! Радий чути, що пояснення було корисним 🙏
Great video as usual ☺️
Thanks! I'm glad you enjoyed it 😊
It would be great to have more AI videos on how to add improvements and the possibility of AI tutorials that are friendly like in stores, banks for buying and selling items, etc. since there is no information on that.
Hey! Thank you for your suggestion, it’s definitely something I’ll keep in mind for future videos. I appreciate your input 🙏
As always the best tutorial maker on youtube, great video thank you !
The only thing that I still don't get is where to use an event dispatcher other than linking an Event in a Component to its owner.
The receiver of an event dispatcher needs a reference to do the binding, making it less modural and lead to casting. So maybe we should avoid using event dispatchers in those cases and reserve it for when the reference is easy to get ? Or did I miss something else ?
Hey, thank you for your kind words! 🌟 You bring up a great point about event dispatchers. To take it a step further and remove the need to get a reference to the actor that is dispatching an event, you can create an "Event Manager" also known as an "Event Bus". Which will allow you to trigger an event from anywhere, and have a central listener that broadcasts it.
For example, the enemy dying can trigger an event. Then the player can listen to all event of any enemy dying without having a reference to any enemy.
I cover this topic in detail in this video and show how to implement it:
th-cam.com/video/y4fE2JdFdvY/w-d-xo.html
@@AliElZoheiry Thanks for the response ! I forgot you hard a video about that, very useful !
Thanks Bro ♥️
@@NatadTech you're very welcome, thanks for watching and commenting
This is exactly what I needed
You're very welcome! I'm glad to hear that it was helpful 🙏
Nice video. It would be cool if you could do a similar video for Gameplay Tags.
Thanks for your comment! I'll definitely add that to my list of video ideas 🙏
first time seeing this channel 45 sec in and im a subscriber!
Hey, thanks for subscribing! I hope you find the content useful 🙏
So incredibly valuable
Thank you! I'm glad you found it valuable 🙏
Love the content, Ive been wanting to learn more about dispatchers. Is a dispatcher only used from a component, or can you use them outside of components? Thanks for the hard work!
Hey, thank you for your kind words! Dispatchers can be used both within components and outside of them. They're a great way to keep your code organized and facilitate communication between different parts of your game. If you have more questions, feel free to ask! 🙏
When you use "Get Actor of Class" or "Get Component by Class" in an attempt to get the actor that is calling the dispatcher, so that you can bind the dispatcher, can this have negative effects for other actors that have different logic but use the same component or class? Let's say that it does cause issues, I've heard that you can also use tags to get specific actors, or storing references to actors in game instances, would these be more preferable or the same? Thanks!
Great video! Could you explain Game Mode and Game Instance as well? Thanks!
Hey! Thank you for your comment! I appreciate the suggestion, and I'll definitely consider covering Game Mode and Game Instance in future videos 😉
Hi, love your videos, keep up the great work.
I would like to ask for a video which I was not able to find anywhere or at least not explained video how it works really. The subject is control rig blueprint. How to control the players character during game- to grab a door handle when opening a door, make character touch a wall in front when moving too close or simular stuff. I followed some tutorials but they never explain how the transforms changes work and I see alot of weird position of arms or legs of which I am sure should not be possible. Thank you.
Hey! Thanks so much for your kind words and your suggestion. Controlling character interactions like that sounds interesting, and I'll definitely consider it for a future video. The way transforms work can be tricky, but I’ll try to clarify that. Appreciate your support! 🙏
ach! I was expecting that! thanks! 👍
@@HumpaLumpaBiriBam you're very welcome, glad you found it helpful 🙏
Awesome vid. My question, when should you use multiple interfaces? Rather than throwing all your stuff in one cohesive interface?
Hey, thank you for the question! It's generally a good idea to use multiple interfaces when you have distinct behaviors or functionalities that may not always be applicable to every class. This keeps your code cleaner, easier to maintain, and more modular. Hope that helps! 🙏
liked before watched, thanks bud
Thank you! I appreciate your support 🙏 Enjoy the video!
Great video!
Thanks! Glad you enjoyed it 🙏
Thanks Ali! The way you explain different concepts is so clear. you really have a talent for this. I have one question though. All of the videos I have watched regarding interfaces, references, and memory usage always use the same example: an interactable interface and an interact function / event. This is great and all but what if I only want to get basic data of an object, like world transform for example, from another object, let's say my player character, without creating a hard reference to that specific object. Is it possible to use BP interfaces for that?
I was thinking of creating a generic BP interface called "reference manager" where I would create functions that declare basic data so I could get them and create variables out of them inside the objects that need a reference to this data.
Hey! Thank you for your kind words, I really appreciate it 🙏 For getting basic information, you should already be able to do that on any actor, you can get the transform of any actor without having a reference to a specific class. So I wouldn't recommend creating an interface for defining functions that might already exist on the actor class.
@@AliElZoheiry Thanks for replying! I'm not sure how it's possible to get an actor's data from another actor's blueprint without creating a hard reference though.
let's say I use the "get actor rotation" node in my player character blueprint and the target is another actor called BP_Box for example. I'm not sure how I can do that without declaring to my BP_PlayerCharacter that BP_Box exists. I know that casting creates a hard reference so I was trying to find a way to easily get basic data from actor to actor without having to create hard references.
In the meantime I found a workaround using a blueprint interfaces and tags which seems to work relatively well
Good explanation! One thing which i always struggling is...when you doesn't have reference to actor for interface/dispatcher call.
In your example it's pretty easy with trace, but imagine case when door actor should ask some global manager actor, can open? (Like when alarm state is active or something). Or manager has to tell all objects to change their states...
In that case door/manager should has hard reference on begin play or hard referenced through level. And i don't have another solution for that, and i really bothered of that because most of the "managers" has many hard references to deal with other things in game.
Hey! Great question, and I'm glad you found the explanation useful 🙏 For managing references like this, all actors can have a hard reference to the "manager" actor itself, that's fine because you expect that actor to always be there and all other actors to depend on it (since it's a global manager), but don't put references to other actors in the manager itself, the manager should be agnostic of other classes.
I have a tutorial on how to build an "Event manager" for usecases like that, check it out if you're interested th-cam.com/video/y4fE2JdFdvY/w-d-xo.html
Another Great video! I'm curious what are other Actor Components you most frequently use besides health?
Thanks for the compliment! Besides health, I often use Components like Movement, Inventory, and many others, though it highly depends on the type of game. If you have any specific use cases in mind, feel free to ask! 🙏
@@AliElZoheiry Thank YOU! Since you asked....! I'm building a single-player, turn based battle + explore game inspired by PS1 final fantasies.
For battle mode - Health as you suggested, I suppose MP for magic abilities.
For explore mode - Inventory as you suggested would be great. So long as the items are unique to explore mode (e.g. keys).
Any other ideas at top of mind?
Sounds pretty good @@WestinsWorldStudio indeed an inventory component could be great for your use case
Awesome fella thank you!
You're welcome! Glad you liked it 🙏
Thank you!
You're welcome! Thanks for watching and commenting 🙏
Thank you for this info
@@michaelbond4609 you're very welcome 😁 thanks for watching and commenting 🙏
Hey love ur tutorial im been using ue damage system from a few week ago but i really want to learn jow to make upgrade and upgrade item pick up like risk of rain like armor ,speed , ability,bla bla..... cause so far only ur tutorial work hope u can help also keep going man ur tutorial is amazing
Update im sorry if i asking to much but it be great to if when u pick up the item it randomize the upgrade that u can pick too hope u can help
Hey! Thank you for your kind words, I really appreciate it 🙏 As for the upgrades, I’ll definitely consider creating a tutorial on that! Stay tuned! 😉
@@AliElZoheiry omg thank you high hope on u man keep it up
Ali your videos are wonderful. I have watched almost all of them, and over the last few weeks I have used a lot of the info for building a basic FPS. However, I've got myself a bit confused. Through your tutorials, I have BPI_Damageable set up, and the Health component set up. This has resulted in a Death custom event and an On_death event in my player character blueprint, and I am not sure which to use. When it comes to these systems, I am confused on which should be integrated with my HUD. Is it better to have the interface pass damage info to the component which then passes the damage to the player character and then the health bar? I am confused enough that I don't know if I am even explaining this properly.
Hey! Thank you for the kind words, I'm really glad to hear that my videos have been helpful for your FPS project 🙏 As for your question, like I said in the video, there is no right or wrong, or one way that's better than the other, you should be using both approaches, and assess which approach is right for your specific use case. I suggest using the information from this video to try to understand which one is better for your specific need.
What is your preferable option for player/UI communication and why? Right now i use interfaces, because my player doesnt have references to all UI elements, only its parent and i also need to pass data from them, but i dont know if this is the best method.
Hey! Interfaces are a solid choice for decoupling your player from UI elements. They provide flexibility since you don’t need direct references. but event dispatchers are useful to notify the UI element that something has happened, like the example I mentioned with decreasing the health percentage on the widget when the player takes damage. So feel free to use both, there is no one size fits all solution
awesome video.
Thanks! Glad you enjoyed it 🙏
Thank you
You're welcome! Thanks for watching and commenting 🙏
Comment after comment straight gushing over this guy's ability to teach. I keep scrolling and they're all saying the same thing using different words. Going to give this a watch and see if it's legit or if guy just rented some bots to flood the comment section.
Fuk... yeah, that was very well constructed and extremely informative compared to the majority of UE content out here. Sorry for doubting. Keep on l, keeping on.
Hey! I appreciate your skepticism-it’s always good to question things. I genuinely strive to educate and not just entertain, I believe that's what the comments are reflecting because there's a lot of content out there focused on getting views only and the content is secondary. I leave a lot of views on the table to cater for those who actually want to learn 🙏
Hello Ali, how are you? I have a question that when I use the animation layer interface, I have to use float variables to communicate the variables in the VR animation blueprint, but I want to use the enum variable to communicate the variables. I asked several people and they said that you can't use enum for communication, because then you can't define the list of variables defined in enum separately, and that variable will actually be unused. What do you think? If we understand, can I ask my question with a picture in discord?
Hey! I'm doing well, thanks for asking. 😊 Not sure what you mean by "can't use enums for communication", enums are basically just an array of integers under the hood, you can use them as you use any variable. I don't see any problem with that
I want to integrate the consolidation system with the inventory system I almost did this, but I can't get the health bar to work
Hey! That sounds like a great project!. Good luck! 🙏
@@AliElZoheiry I think so and the mission was completed successfully
Hi! I really like your video! Could you please make a video about data assets and best way to create content for project? Because for now I could use data assets, data tables, raw blueprints for some data and etc. I want to understand, when I should use every stuff, thank you!
Hey! I'm glad you liked the video! Thanks for the suggestion, that's a great topic. I'll definitely consider making a video on data assets and when to use each type. Stay tuned! 🙏
Ali there is a Project i wish you work on A game like Conquer online Topdown with all its features and add the Ai Series on top of it this will be Massive 😊
@@MohamedKhaled-CR7 sounds like years of work 😅 but I'll definitely consider some elements from topdown RTS games for future videos
@@AliElZoheiry Thx Ali ❤️❤️
Hello and thank you for this great video! I really like your work and your voice 😊.
Do you think it’s a good idea to add some Cast To (player controller, game mode, etc.) in the Game Instance, promote it to a variable, and load it during the Loading Page to use it whenever needed without using more resources?
Thank you very much.
Hey! Thank you for your kind words 😊
It's definitely a good idea to cast to your custom framework classes and store references for those. It has no impact on memory since these classes are always loaded into memory anyway, so don't worry about casting or storing references to them
@@AliElZoheiry Ok, it's good to know! Thank you so much to always take the time to answer. I think you're a really kind person 🙏🏽
Hi, thank you for the tutorials, I have been watching your videos for a while.
I have a design question, I want to make a simulation game in UE5, but I don't know where to start. There's barely any information about it online. The goal is, NPC simulating, doing stuff, having their own schedule and conflict, interacting with each other, even the player is not around, make them have their own persistence.
It's kinda like a backend simulation, do you have any tips on how to achieve something like this?
If you need example, something like what X4: foundations did on their simulation, but in UE5.
Hey! Thanks for your support and for watching my videos 🙏
For a simulation game with persistent NPCs, I'd recommend starting by breaking down your design into smaller systems. Focus on creating an NPC behavior manager to define how they interact, their schedules, and conflicts. Implementing a state machine can help manage their behaviors effectively.
You might also want to look into using data structures to store NPC states and schedules, enabling them to function independently. It's a complex project, but breaking it down can make it more manageable. Good luck
@@AliElZoheiry Thank you so much, I'll try get started looking into these things and study them.
Thanks for pointing me out in the right direction. I really needed this one. I'm kinda at a loss.
So if you wanted your player to be able to push a button to open a door, there would be an interface implemented between the player and the button, and an event dispatch between the button and the door?
Well it depends on a lot of things, but generally speaking, if you have multiple different kinds of doors, all with their own unique "Open" function. Then yes, you would have a door interface, and the player just calls an "Open" function on that door reference without caring what type of door it is.
Then if you want the door to notify the player when it's fully open, you can then indeed dispatch an event from the door saying where the player listens to it, and then knows it's fully open when it's called
hi, you are a great teacher. What do you do for a living? Amsterdam is very expensive
Hey! Thank you for your kind words 🙏 I am a software engineering manager. It's definitely a challenge, but I enjoy it!
Legendary. Nothing else to add to my comment.
Thank you for your kind words! I appreciate it 🙏
Would this be a good way to have Actor components of the same actor communicate as well?
Hey! If you have different actor components on your actor, you can definitely have them communicate together, as long as they first check if the other component is valid or not, so that they don't make the assumption that it will always be there
Tbh, I'm still confused about what the difference is? You can call an Event dispatcher or an interface, and you will get the same result + without casting, the only difference I can see is that Event dispatchers can't have a function like interfaces, but they are the same with Events. 18:40 What did you mean by "Makes an assumption....and doesn't allow you to make anything else, can't extend it" can you give an example?
BTW you are underrated, thanks for all the hard work, been enjoying your videos recently
@@Rix1Dev Try asking the chatbot and let me know if it explains it well, if it doesn't, I'll try to give it another go ;)
While Event Dispatchers can be used to trigger events, they don't provide the same level of flexibility as interfaces. Interfaces allow you to define the exact behavior that implementing classes must follow, ensuring consistency and modularity. Event Dispatchers, on the other hand, simply broadcast events without enforcing any specific behavior.
For example:
You would Event Dispatch a change to an attribute, like Health and have an Interface for the TakeDamage.
The TakeDamage interface would be sent to the actor when it is hit. If the actor implements the interface TakeDamage, it would react accordingly (for this example, let's say it reduces its health on its StatsComponent.)
The actor sends the function of ChangeHealth to the StatsComponent to change the Health variable. Once the variable has been changed, the StatsComponent then broadcasts (Call) the OnHealthChanged dispatch.
The health UI (User Interface) is setup to listen for any broadcasts when the OnHealthChanged Event Dispatcher is called out (Bind). It then changes the UI to reflect the current Health status.
As a bonus, your weapon is also listening for the OnHealthChanged dispatch, and when it receives the message, it begins to glow brighter and brighter the lower your health gets.
Both of those happen at the same time. The main difference is that the TakeDamage had to be sent to the actor, otherwise it does nothing at all. The OnHealthChanged is announced and just works.
Think of a scenario where you have a commander NPC on your team that provides a stat boost to all allied troops. When the commander dies, it could fire off an event that would trigger each individual troop NPC to receive that event and act on it. In fact, the troops could use an Interface on what to do with that event, fighters atk drops, mages spellpower drops, etc. If you just use interfaces, you would need to cycle all of your NPCs to run the Interface function. Also, where would you initiate this loop? In the commander death routine? That increases the coupling between the commander and troops. Event dispatchers allow objects to communicate a specific event to other objects then let them handle it independently. Interfaces allow different objects to handle events uniquely based on their specific characteristics. Least that was my take away.
@@Yggdrasil777 Thx for your time writing this!
@@MarekGamer76 "That increases the coupling between the commander and troops." aha ok, thats what I wanted to hear + it would be easier to Call and Bind than implementing Interface on all actors, Thx .
Hi Ali !
hope you're doing well !!
when the next of game dissecting series will be release ?
wish you all the best !
sorry for my english 🙂
@@abdoulraoufgambo I was thinking of some mechanic from Black Myth Wukong. What do you think?
@@AliElZoheiry that would be cool !
Consider I would have a pickable item in my game and I also have an Inventory Component for my Character.
Is it feasible to update my Inventory Component (Like number of bandages) using event dispatchers ?
I mean after I've picked up something(a bandage :) ) I call a dispatcher to update my inventory.
Thanks :)
Hey! Yes, using event dispatchers to update your Inventory Component when picking up items is definitely a feasible approach. It’s a clean way to decouple the pickup logic from the inventory management. Just make sure your dispatcher is set up properly to handle those updates. Hope that helps! 😉