Just found your channel and watched all of your UE5 videos, and saved them for future reference. Such good and clear information and explanations, I love it. If you made a full UE5 course I'd buy it in a heartbeat.
With the exception of Interfaces, most things within Unreal always tend to fall back on Hard References. This just increases the memory load per actor and things become much worse when those referenced actors are also referencing other actors as well. This is why coming from other game engines that do this system a lot better, I was put off by Dispatchers when I first started using Unreal. I feel that still having to cast, just defeats the whole purpose of even having a messaging system in the first place. And although he may have been able to get away with it for the first example, since he happened to be spawning an object into the world, in most situations, dispatchers still mostly rely on hard references to relay messages to the thing you are trying to communicate with. I could just as easily cast to an actor from another one and call the custom events within that actor from the one im using to cast with. And if those other actors inherit from the same class, I could just as easily execute the same call on all of those actors as well. Then what would even be the point in using the dispatcher in the first place? Dispatchers also take just as much time, if not more, to set up as Interfaces do. This is because not only do you have to also create a custom event, you have to set up the call, the cast to get a ref to the actor, and also the bind. There are a significant amount of steps. Interfaces are so much better because you save on memory since they are only weak pointers to the things that are already loaded in memory from the time the game is launched. You can also clear the arrays from retrieved actors, which helps a lot with potential bottle necking. With an Interface, I could have 3 objects respond to a single event call without having to cast to them or risk creating a daisy chain of dependency.
@@ChatterBoks85 I think there is a difference between Soft References and Hard References regarding the loading into Memory. As I remember with soft reerences there is no loading of dependencies until they are being used. I watched a youtube Video about it explaining it I think .
Casting works for 99.999% of games. The only time it is bad practice is if you're making an MMO or a AAA sized game. No indie dev is going to see an issue with casting.
Been looking across tutorials for days to figure out where upon EndOverlap I could trigger access to multiple doors, and the light portion of the tutorial helped me connect the dots. Excellent video, thank you!
Thank you very much for this video. It helped connect some dots and really brought the _point_ of EDs home to me. At the end you briefly show unbinding but then in editing cut away from why that may be useful. Let's imagine the 9 wall lights from earlier in the video again. There's the pressure plate in the video that turns them all on. Now let's imagine this is actually a puzzle, and you want the player to create a specific pattern on the wall. When you flip a switch somewhere else in the level, the middle lamp needs to stop responding to the pressure pad. The rest of the lamps isn't concerned with this interaction in the slightest, nor does the switch you flipped care (or even know!) about any lamps. The middle lamp is "listening" for this switch, and also "listening" to the pressure pad, and when it receives the Event Dispatcher from the switch-flip (set up exactly as shown in the video with the pressure pad), it wants to "stop listening" to the pressure pad. So flip switch -> Event Dispatcher ----> Lamp triggers the Event that listens for the switch flip -> unbind from the Pressure Pad Event Dispatcher. And now, when you walk on the pad, the middle lamp stays off. :) And if you flip the switch again, we can re-subscribe to the pressure pad's "being stepped on" Event Dispatcher. P.S. Totally unrelated but the way the _Avorion_ modding API works is essentially one huge ball of Event Dispatchers. I really grew to know and love the concept there, and finally with this video I've made the last "click" I needed to fully know and love them in Unreal too. Thanks!!
I must say I really love your tutorials, you go straight to the point, explain it really well. I saw multiple tutorials on interfaces and other stuff and noone explained it that well, many times they complicate it. You keep it simple. Well done , keep up your work
11:57 It's more performant to create an overlap only player collision preset on the trigger volume. Source: Unreal Fest 2023, George Prosser's talk, worth a watch!
You forgot (or maybe didn't know) one important detail: You don't need to hold the reference after binding the event. You only need that reference if you later unbind the same event. But, if you intend to 'set and forget' the binding, such as with your day night cycle, you can null the reference after binding. This can also be used in cases where you will be able to get the reference again later for unbinding, or where you fall back to a soft reference to save memory, and later will resolve/async load it back to a hard reference to perform the unbinding.
@@TylerSerinoI'm very much of the mindset "how does this actually work?" From removing array indices to this.. I start by prototyping to test "but what if.." And yeah, that's how I found this out. Honestly.. It's less pure curiosity, more paranoia that it'll do something I didn't expect.
Could you elaborate on this a little? I am making a day/night cycle controlled by a timer in my GameMode_BP. I would like the timer hitting zero to call "turn night/day" in my Town_BP. However I am getting stuck at needing a ref in my Town_BP for the 'bind event'. I could Cast from TownBp to GameModeBP, but that destroys the point of dispatching in this case.
@HighTv420 you’ll still have to cast to your game mode, it doesn’t defeat the purpose because your game mode won’t rely on your town bp in any way. But yea anything that you want to use to bind to an event in your game mode is going to have to cast to the game mode
My man, You are my hero, I was looking to find a way to use CTRL and Up and down to create a function for the character and animation to communicate EVERYONE told me to use Interfaces, But that was exacly bull shit i needed Event dispatchers, THANK You so much. I came Totaly random on this video and this helps me allot. Thank you so much man you made my project much easyer
A question regarding performance (memory usage), in your second example with the lamps, you create a reference variable to the trigger, which you then select in the viewport. Isn't this creating a hard reference, like in casting? Ignoring here the advantages of Event Dispatchers over Casting, just curious about the performance regarding the reference. Is this kind of communication only possible with references, or is there a way that doesn't need any implementation of the sender?
Thank you so much for all of your Content. Studied a ton of „tutorials“ last couple of weeks. You are pretty much on the top for me! Question: on min 11:53 , What would be the better way to dodge this Cast to? My goal is to pickup weapons without hardcasting to them… is there a way to use BPIs/Dispatcher in combination with OnComponentOverlaps instead of triggers? Ty again for all your good work.
you prolly figured it out but for anyone else, the way to dodge a cast would be to create a BPI_Interactable with an Interact Function with a set keybind and then in the weapon BP, add the event for Interact and use a branch node to check if your player pawn is overlapping with the weapon's pickup range collision and then fire the event of picking up the weapon. This decouples and binds the interactability to the weapon BP rather than making the weapon cast to the Player BP per overlap. There should be better ways to do this as well but I hope this helps :)
Good video! I didnt go through all the comments, so I'm sorry if it's already been said, but you can use the shorthand "Assign on [Dispatch Call Name]" which will bind AND create the custom event for you. :)
Great video, but there's no need to store a reference to the trigger. That makes a dependency and means that the lights don't work properly without the trigger. Just do the same dispatching as before and tell the lights to listen for the trigger's dispatch events (one for On Begin overlap and one for End Overlap). Also, instead of casting to the Player, just use the has tag node and give the player a tag of Player.
What’s the best way to send a float value across multiple blueprints? I have some cool audio visualizer ideas. It’s harder than I thought to get it to work!
Out of curiosity, at 12:16 would a tag be a better way of ensuring that it isn't a projectile (or anything else you don't want it to be) than casting to?
To be entirely honest with you, I'm not sure. I looked it up and all I could find were some speculatory comments that searching for tags could be less performant. Intuition would tell me that you'd be right. Good question though! If I ever find an answer ill let you know.
In the second example you gave with the pressure plate- how would you get reference for the pressure plate if the component you are binding the event dispatcher to isn't a physical object in the scene (for example the AIPerception component in an AI Controller blueprint)? I'm basically doing that exact example but when the player overlaps with a collider, it creates an event dispatcher that deactivates the AIPerception component in the AI Controller blueprint.
Whether or not its a physical object, in order to get an object reference, the class must be instantiated - meaning in the world. If memory serves me correctly, the AI controller is referenced by the character you are controlling, no? You should be able to get it with a reference to your ai. Furthermore, I believe there is a node called "Get Ai Controller".
Can you use soft reference and load it when you enter the room for example, to minimize the hard references and memory/disk size each light would have?
but the lamps are referencing the platform.. seems to be hard binding there. would be nice if we could get a loose binding, so I can create other switches that can turn on the lights without having to create a reference from the light to the swtiches.
I want to have an Alignment system in my game, good/neutral/bad, changes based on what the player does to represent their playstyle. This seems like how I would handle that?
So the dispatchers, even though the objects are you said, "waiting" for the trigger to happen, are they always loaded or active like they are in casting?
In the case with the lights and the button, how does an event dispatcher solution compare to an interface solution? I see a lot of similarities between the two, but because of that, I sometimes have trouble choosing which one to implement. Awesome video nonetheless! :)
So In general, I use event dispatchers when I’m not entirely sure what might need to bind to them, as a way to give access to certain functionality in actors or components, without creating any other dependencies. An example I give in the video is components: take the projectile motion component for example - you want to just be able to slap that on something and have it work without having to add any additional interfaces or otherwise. At the same time, there may be events or functions running in that component that you want the owning actor to know about on a case by base basis. With interfaces, you can slap them on a given object in order to give them a set of functions and events that you can reference from elsewhere without needing a direct reference. The best example there is an interaction system - you may have a ton of different interactable objects, and your player may be tracing for them with a line trace which just returns a generic actor. You can use that generic actor to call those interface functions without needing to cast.
Would it be viable to use GamePlay Tags for the overlap check in the platform and lights example? That could spare the cast to FirstPersonCharacter, right?
Last I recall, you need to access a given object directly to get it's gameplay tags no? If you're talking about regular actor tags, I believe you could use the does actor have tag node directly from the output, but iirc gameplay tags aren't on the base actor class
Maybe better than a cast for the character, give the player a "Character" tag, and then have the button do a tag query, if the interacting actor has the has the "Character" tag, you are good to go, if not end.
Well you still need a reference to whatever event dispatcher you’re trying to bind to but in general I sometimes find it more efficient to cast when I’m trying to get a reference to something that I know will always be loaded, or at least will always be loaded at the same time as the object casting. Ie casting to the player from the players widget or vice versa is generally safe as far as I can tell.
@@cosmotect Those are really the big 3 for blueprints. The only other one I can think of are just simple direct references, ie you have a variable that you manually set to your object via the details pannel in the world.
Channel is cool but you need to slow down on connecting some of those blueprint boxes... you go SO FAST I have to replay the video multiple times to get the details down
When I first got into Unreal I was mystified at how to add a listener to a variable, or bind an event to a variable. Then I realised I learned that habit from Flash development and it was bad practice. Ever since I have followed Epic's best practice and it has never let me down. Some things aren't intuitive but the majority is. Events can be tricky. I came here looking for a way to store a delegate as a variable because I saw it once and never figured it out. But no joy here. Onwards.
One simple (dumb) mistake I made with my event dispatcher. Solved it for me within the first 3 minutes of the video. Thank you!
Just found your channel and watched all of your UE5 videos, and saved them for future reference. Such good and clear information and explanations, I love it.
If you made a full UE5 course I'd buy it in a heartbeat.
less casting, more dispatcher and BP interface, totally with you
With the exception of Interfaces, most things within Unreal always tend to fall back on Hard References. This just increases the memory load per actor and things become much worse when those referenced actors are also referencing other actors as well. This is why coming from other game engines that do this system a lot better, I was put off by Dispatchers when I first started using Unreal. I feel that still having to cast, just defeats the whole purpose of even having a messaging system in the first place.
And although he may have been able to get away with it for the first example, since he happened to be spawning an object into the world, in most situations, dispatchers still mostly rely on hard references to relay messages to the thing you are trying to communicate with.
I could just as easily cast to an actor from another one and call the custom events within that actor from the one im using to cast with. And if those other actors inherit from the same class, I could just as easily execute the same call on all of those actors as well. Then what would even be the point in using the dispatcher in the first place?
Dispatchers also take just as much time, if not more, to set up as Interfaces do. This is because not only do you have to also create a custom event, you have to set up the call, the cast to get a ref to the actor, and also the bind. There are a significant amount of steps.
Interfaces are so much better because you save on memory since they are only weak pointers to the things that are already loaded in memory from the time the game is launched. You can also clear the arrays from retrieved actors, which helps a lot with potential bottle necking. With an Interface, I could have 3 objects respond to a single event call without having to cast to them or risk creating a daisy chain of dependency.
@@ChatterBoks85 I think there is a difference between Soft References and Hard References regarding the loading into Memory. As I remember with soft reerences there is no loading of dependencies until they are being used. I watched a youtube Video about it explaining it I think .
Casting works for 99.999% of games. The only time it is bad practice is if you're making an MMO or a AAA sized game. No indie dev is going to see an issue with casting.
@@TH-camAccountMan wow, what a precise number you provided. you seem to have done quite som investigation :)
@@lazykid9167 yeah 😂, no loss in learning the better optimized way tbh, no matter how heavy or light your game is!
Excellent video - "All the components in Unreal deserve a video of their own" - please make these videos!
Been looking across tutorials for days to figure out where upon EndOverlap I could trigger access to multiple doors, and the light portion of the tutorial helped me connect the dots. Excellent video, thank you!
Thank you very much for this video. It helped connect some dots and really brought the _point_ of EDs home to me.
At the end you briefly show unbinding but then in editing cut away from why that may be useful. Let's imagine the 9 wall lights from earlier in the video again. There's the pressure plate in the video that turns them all on. Now let's imagine this is actually a puzzle, and you want the player to create a specific pattern on the wall.
When you flip a switch somewhere else in the level, the middle lamp needs to stop responding to the pressure pad. The rest of the lamps isn't concerned with this interaction in the slightest, nor does the switch you flipped care (or even know!) about any lamps. The middle lamp is "listening" for this switch, and also "listening" to the pressure pad, and when it receives the Event Dispatcher from the switch-flip (set up exactly as shown in the video with the pressure pad), it wants to "stop listening" to the pressure pad.
So flip switch -> Event Dispatcher ----> Lamp triggers the Event that listens for the switch flip -> unbind from the Pressure Pad Event Dispatcher. And now, when you walk on the pad, the middle lamp stays off. :)
And if you flip the switch again, we can re-subscribe to the pressure pad's "being stepped on" Event Dispatcher.
P.S.
Totally unrelated but the way the _Avorion_ modding API works is essentially one huge ball of Event Dispatchers. I really grew to know and love the concept there, and finally with this video I've made the last "click" I needed to fully know and love them in Unreal too. Thanks!!
I must say I really love your tutorials, you go straight to the point, explain it really well. I saw multiple tutorials on interfaces and other stuff and noone explained it that well, many times they complicate it. You keep it simple. Well done , keep up your work
11:57 It's more performant to create an overlap only player collision preset on the trigger volume. Source: Unreal Fest 2023, George Prosser's talk, worth a watch!
My dude your tutorials are great! Simple and to the point; I love it!
Really liked the whole BP communication trilogy
You forgot (or maybe didn't know) one important detail:
You don't need to hold the reference after binding the event.
You only need that reference if you later unbind the same event.
But, if you intend to 'set and forget' the binding, such as with your day night cycle, you can null the reference after binding.
This can also be used in cases where you will be able to get the reference again later for unbinding, or where you fall back to a soft reference to save memory, and later will resolve/async load it back to a hard reference to perform the unbinding.
Truth be told, I never even thought to do that. That's actually extremely interesting, thanks for that!
@@TylerSerinoI'm very much of the mindset "how does this actually work?"
From removing array indices to this.. I start by prototyping to test "but what if.."
And yeah, that's how I found this out.
Honestly.. It's less pure curiosity, more paranoia that it'll do something I didn't expect.
Could you elaborate on this a little? I am making a day/night cycle controlled by a timer in my GameMode_BP. I would like the timer hitting zero to call "turn night/day" in my Town_BP. However I am getting stuck at needing a ref in my Town_BP for the 'bind event'.
I could Cast from TownBp to GameModeBP, but that destroys the point of dispatching in this case.
@HighTv420 you’ll still have to cast to your game mode, it doesn’t defeat the purpose because your game mode won’t rely on your town bp in any way. But yea anything that you want to use to bind to an event in your game mode is going to have to cast to the game mode
My man, You are my hero, I was looking to find a way to use CTRL and Up and down to create a function for the character and animation to communicate EVERYONE told me to use Interfaces, But that was exacly bull shit i needed Event dispatchers, THANK You so much. I came Totaly random on this video and this helps me allot. Thank you so much man you made my project much easyer
Great explanation!
I was doing exactly what you pointed out with the many-to-one relationship and exactly with spotlights XD
Cheers!
Events seem a very powerful approach to many scenarios, thanks for showing us!
This video is clear and useful, the example you used is just perfect. thanks for sharing! 🥰
Thank you! You are the one who explain things really well
Another great, comprehensive video. Glad I found your channel.
2:15 my timestamp. adding the event dispatcher.
4:47, got basics down for how to create and use an event dispatcher at the most basic level.
Great tutorials, wonderfully explained! Looking to create a day/night system and would love to see your tutorial on that
A question regarding performance (memory usage), in your second example with the lamps, you create a reference variable to the trigger, which you then select in the viewport. Isn't this creating a hard reference, like in casting? Ignoring here the advantages of Event Dispatchers over Casting, just curious about the performance regarding the reference. Is this kind of communication only possible with references, or is there a way that doesn't need any implementation of the sender?
0:00 First use case
8:41 Second use case
14:50 Third use case
Thank you so much for all of your Content. Studied a ton of „tutorials“ last couple of weeks. You are pretty much on the top for me!
Question: on min 11:53 , What would be the better way to dodge this Cast to? My goal is to pickup weapons without hardcasting to them… is there a way to use BPIs/Dispatcher in combination with OnComponentOverlaps instead of triggers? Ty again for all your good work.
you prolly figured it out but for anyone else, the way to dodge a cast would be to create a BPI_Interactable with an Interact Function with a set keybind and then in the weapon BP, add the event for Interact and use a branch node to check if your player pawn is overlapping with the weapon's pickup range collision and then fire the event of picking up the weapon. This decouples and binds the interactability to the weapon BP rather than making the weapon cast to the Player BP per overlap. There should be better ways to do this as well but I hope this helps :)
Excellent. Please make more. at the end of the video when unbinding. Is there a way to check if bound so no errors are thrown?
Great video! Waiting for day and night cycle tutorial.
Good video! I didnt go through all the comments, so I'm sorry if it's already been said, but you can use the shorthand "Assign on [Dispatch Call Name]" which will bind AND create the custom event for you. :)
THANK ! YOU ! I finally understand that system and its power ! ❤
This is the best thing EVER! Thank you!!!
Great video, but there's no need to store a reference to the trigger. That makes a dependency and means that the lights don't work properly without the trigger. Just do the same dispatching as before and tell the lights to listen for the trigger's dispatch events (one for On Begin overlap and one for End Overlap). Also, instead of casting to the Player, just use the has tag node and give the player a tag of Player.
Wonderfully explained, liked and subbed!
This really useful, thanks! This will take some getting use to though
What’s the best way to send a float value across multiple blueprints? I have some cool audio visualizer ideas. It’s harder than I thought to get it to work!
Out of curiosity, at 12:16 would a tag be a better way of ensuring that it isn't a projectile (or anything else you don't want it to be) than casting to?
To be entirely honest with you, I'm not sure. I looked it up and all I could find were some speculatory comments that searching for tags could be less performant. Intuition would tell me that you'd be right. Good question though! If I ever find an answer ill let you know.
In the second example you gave with the pressure plate- how would you get reference for the pressure plate if the component you are binding the event dispatcher to isn't a physical object in the scene (for example the AIPerception component in an AI Controller blueprint)?
I'm basically doing that exact example but when the player overlaps with a collider, it creates an event dispatcher that deactivates the AIPerception component in the AI Controller blueprint.
Whether or not its a physical object, in order to get an object reference, the class must be instantiated - meaning in the world. If memory serves me correctly, the AI controller is referenced by the character you are controlling, no? You should be able to get it with a reference to your ai. Furthermore, I believe there is a node called "Get Ai Controller".
Can you use soft reference and load it when you enter the room for example, to minimize the hard references and memory/disk size each light would have?
but the lamps are referencing the platform.. seems to be hard binding there. would be nice if we could get a loose binding, so I can create other switches that can turn on the lights without having to create a reference from the light to the swtiches.
Thank you! Great video 👍
Thank you for the video, very nice explanation!
How would this compare to a soft reference for efficiency and memory usage?
Awesome explanations !!
I want to have an Alignment system in my game, good/neutral/bad, changes based on what the player does to represent their playstyle. This seems like how I would handle that?
So... event dispatchers just weaker the coupling between classes instead of decoupling classes,right?🤨
So the dispatchers, even though the objects are you said, "waiting" for the trigger to happen, are they always loaded or active like they are in casting?
Are there any benefits to using an event dispatcher over a blueprint interface?
In the case with the lights and the button, how does an event dispatcher solution compare to an interface solution? I see a lot of similarities between the two, but because of that, I sometimes have trouble choosing which one to implement. Awesome video nonetheless! :)
Hey, great tutorial. Thanks!
Thanks for this video!
My pleasure! Glad it was helpful
Super useful, thanks a lot
Slapping a like to this one. sLAP SLAP Slap.
thanks for the tutorial!
When would you use an Interface instead of a dispatcher?
So In general, I use event dispatchers when I’m not entirely sure what might need to bind to them, as a way to give access to certain functionality in actors or components, without creating any other dependencies. An example I give in the video is components: take the projectile motion component for example - you want to just be able to slap that on something and have it work without having to add any additional interfaces or otherwise. At the same time, there may be events or functions running in that component that you want the owning actor to know about on a case by base basis. With interfaces, you can slap them on a given object in order to give them a set of functions and events that you can reference from elsewhere without needing a direct reference. The best example there is an interaction system - you may have a ton of different interactable objects, and your player may be tracing for them with a line trace which just returns a generic actor. You can use that generic actor to call those interface functions without needing to cast.
Would it be viable to use GamePlay Tags for the overlap check in the platform and lights example? That could spare the cast to FirstPersonCharacter, right?
Last I recall, you need to access a given object directly to get it's gameplay tags no? If you're talking about regular actor tags, I believe you could use the does actor have tag node directly from the output, but iirc gameplay tags aren't on the base actor class
Thank you!
Instead of Bind Event you can use Assign Event to automatically make Custom event with Call
Maybe better than a cast for the character, give the player a "Character" tag, and then have the button do a tag query, if the interacting actor has the has the "Character" tag, you are good to go, if not end.
Epic, cheers
can we have a tutorial on every aspect of GameMode? 😁
Would you mind to share the source code?
I wish I learned this sooner... T^T
So why would you ever cast?
Well you still need a reference to whatever event dispatcher you’re trying to bind to but in general I sometimes find it more efficient to cast when I’m trying to get a reference to something that I know will always be loaded, or at least will always be loaded at the same time as the object casting. Ie casting to the player from the players widget or vice versa is generally safe as far as I can tell.
@@TylerSerino Gotcha, thanks :)
Another small question. We got interfaces, dispatchers and casting, is there other types of communication?
@@cosmotect Those are really the big 3 for blueprints. The only other one I can think of are just simple direct references, ie you have a variable that you manually set to your object via the details pannel in the world.
@@TylerSerino I see. Thanks a lot!
@@cosmotect Material parameter collections and the like.
Channel is cool but you need to slow down on connecting some of those blueprint boxes... you go SO FAST I have to replay the video multiple times to get the details down
th-cam.com/video/r20VEPH_e0o/w-d-xo.html
I use these but never worked out this step. Thanks.
It's just such a horrible, clumsy system. I don't find Blueprint particularly intuitive either.
When I first got into Unreal I was mystified at how to add a listener to a variable, or bind an event to a variable. Then I realised I learned that habit from Flash development and it was bad practice. Ever since I have followed Epic's best practice and it has never let me down. Some things aren't intuitive but the majority is. Events can be tricky. I came here looking for a way to store a delegate as a variable because I saw it once and never figured it out. But no joy here. Onwards.
Love your work. 🫶