Unreal Engine 4 SnackSize - Event Dispatchers

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hi everyone and welcome back to a snack size video in learning how to use Unreal Engine 4 in this video we're gonna cover the topic of event dispatches what they are how to use them and why would we use them so an event dispatcher essentially it's a way of making blueprints able to communicate to each other without necessarily specifically knowing who is doing the communicating so we can go through some examples are setting it up and what you could use them for and that hopefully will excel PUE understand what they're doing so to create an event dispatcher I've gone into my first person character by the way you make it on the actor screen down the bottom left you'll see event dispatches is underneath your variables an Ingo new event dispatcher to add a event dispatcher so I'm click on plus event dispatcher and we call it test event dispatcher so this event can be triggered and bound to another actor so what we do in my first person character here is only to do the calling here so I'm gonna do a simple tab input so one push the tab key this will file and I'm gonna drag in my event dispatcher and choose cold so now when I push tab especially going to shout out this event dispatcher has been fired okay so this has done something now what we need to do is we create an actor which is gonna bind an event towards listening out for this event happening so I think of it like a megaphone this will shout out and scream out - anyway that's listening and all the actors that are chosen to be listened to this event will then react accordingly so let's do an example for this so you can see it working to create a new act or blueprint class and we'll quiz one test event and we're gonna open this up go to your vent class and on begin play we need to bind an event to it so to do that we need to get first of all the actual player character because that's where the event belongs so you'd get the the player-character at start and cast to them and after that we've got the link now towards the first person character which we can drag out and then bind event and we can bind many events but we want to point the test event dispatcher so this is now going to bind an event that we plug into here towards that test event dispatcher so I'm going to drag from my event pin go down and do custom event and we'll call it test event dis and we'll do a simple print string event dispatches are useful so now when I put this into the world alright when the game begins it's going to get the player character and bind that event dispatcher to that test custom event that means that events now waiting and listening out for when that event happens on the player character and when it does it put in the string okay so really really cool stuff we can communicate now between these two actors and not they're not reliant on each other so it wants to set up that's it it can it's done it's now listening out the whole entire time now where it can just be useful well we can also only do a binding too many other things one such thing I found quite useful is binding to an event called take any damage and what this means is I would usually dissin of widget and on the widget I can then bind a custom event to this called update health or whatever and on my custom widget this is well link up my players health towards the UI so when the player receives damage this will update and update the UI accordingly that way it is really efficient and not constantly ticking to check what the players health is it's just using this bind event here now several other point events which you'll find based on whatever pin you're dragging from so in this case we're drinking from the first person character so we we see things there are actor generic like the inputs we click on a actor for example or overlap an actor which you go up here but you also got character based ones such as when you update the movement mode so if the players suddenly start swimming you may want to change the wire to be swimming or underwater breath for example it's stuff like that if you want to I don't know when the player is destroyed or when the actors destroyed it can do stuff too as well now you also see the option to unbind event and that basically undoes this okay so for whatever reason maybe you want to turn power off of a switch for example and a switch you can tell it to bind and unbind based on what power it's receiving that way you can really make it quite dynamic inside the game and not to having to constantly check what the player is doing at that moment in time another thing you can do event dispatches is also passed variables into them so if you select on your event dispatcher on the right hand side you can see inputs and here you can add a new parameter so for example I can click on new parameter and a type in text and open type of string and here I can type in whatever I want so here I can put in maybe I know hello Ryan so now I'll push tab it's not just calling this event it's now sending over some data along with it then when I go to bind this one again need to update this again so this put this in to bind test event dispatcher this time when I create custom event it's gonna bring along that parameter with it like so and I can use that for whatever I want to use it for there you go so say there's lots of uses for them and the time when you want to use them is when you want something to react to an event that happens on another actor but you don't necessarily know when it's gonna happen and you don't necessarily know which it's gonna happen so an example I've used in the past is switches for doors a door I've tied to a switch for just linking it in the editor and then what I've done is when the switch is activated it the door is listening out for that switch so when the switch is activated the door will open something similar like that and that's which then can be placed anywhere in the level and that door was still open so I have to do any of it a special coding that I've to do anything in another blueprint it'll just work for it nice and easily and put a seal at video you can search for my doors tutorials and you'll find their doors are switched into a tutorial and now just about do it for events dispatches thanks very much for watching if you have any requests for particular nodes or tools inside unreal and know how to use them please leave a comment below I've been trusting to see what you want to learn thanks again for watching and I'll see you all next time bye bye [Music]
Info
Channel: Ryan Laley
Views: 22,055
Rating: undefined out of 5
Keywords: Documentation, docs
Id: HLHueQLKcGc
Channel Id: undefined
Length: 8min 12sec (492 seconds)
Published: Wed Jul 15 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.