How To Use Event Dispatchers And How They're Diffrent To Blueprint Interfaces In UE4 and UE5

Поделиться
HTML-код
  • Опубликовано: 15 сен 2021
  • Updated Discord invitation: / discord #UnrealEngine #VR #VirtualReality
    ► Join the Discord: / discord
    ► Description
    In this video, I show you how to use event dispatchers and how they can be used to make blueprint communication easier and to reduce the number of variable references one blueprint might need.
    -----------------------------------------------------------------------------------------------------------
    ► Patreon: / gamedevxr
    ► Twitter: / gamedevxr
    ► Instagram: / gamedevxr
    -----------------------------------------------------------------------------------------------------------
    If you're new to VR and want to get started with Oculus Quest development, I recommend watching these videos first.
    1. Installing UE4 from Source code (contains more up to date Quest features)
    • Installing UE4 4.25 fr...
    2. Installing Android Studio (Required to create Oculus Quest projects in UE4.25+)
    • Installing Android Stu...
    3. My Oculus Quest 1 Settings (These are different to the Quest 2)
    • My Oculus Quest 4.25 B...
    4. My Oculus Quest 2 Settings
    • Quest 2 Settings You S...
    -----------------------------------------------------------------------------------------------------------
    PC SPECS:
    ► RTX 2070 Super
    ► I9-9900K
    ► 32GB Ram
    ► 2TB SSD
    Equipment
    ► Keyboard: HyperX Alloy Origins
    ► Mouse: Anker® Ergonomic Optical USB Wired Vertical Mouse
    ► Mic: Trust GXT 232
    ► WebCam: Jelly Comb
    ► Screen: AOC I2367fh 23-inch LED x 2
    ► Headset 1: Oculus Quest 128GB
    ► Headset 2: Oculus Rift + Motion Controllers
    ► Headset 2: Oculus Quest 2
    ► Graphics Tablet: Wacom Cintiq 13hd
  • ИгрыИгры

Комментарии • 28

  • @MetaIsland
    @MetaIsland 15 дней назад

    Very well done!

  • @musikalniyfanboichik
    @musikalniyfanboichik 2 года назад +3

    incredible content tysm

  • @thomaskneisel1854
    @thomaskneisel1854 Год назад

    So funny, i watched your last Video about casting vs interfaces 5 minutes ago and almost ask in the comments why not using a event dispatcher instead :D ... great content thanks a lot

  • @BrianScotland
    @BrianScotland 2 года назад

    Thank you. Im learning UE 1 piece at a time.

  • @richmind5867
    @richmind5867 2 года назад +5

    omg thank youuuu. I am a true beginner i never did this before and i want to start with blue print before i learn anything else. I am learning other things little by little but blueprint is my main focus.

    • @GDXR
      @GDXR  2 года назад +1

      You can do it!, just keep going with it. Blue prints is pretty easy tbh so you should have no problem.

    • @richmind5867
      @richmind5867 2 года назад +1

      @@GDXR im trying to learn c++ i heard it's the professional way. i dont want to limit my game.

  • @msinclaircorp4571
    @msinclaircorp4571 Год назад

    HI, nice video man, thanks, very well splain, you are the best!, question what happen when do that but in multiplayer?

  • @rifat.ahammed
    @rifat.ahammed Год назад

    Thank You

  • @chasesommer
    @chasesommer 4 месяца назад

    Thanks big papa

  • @thelawgameplaywithcommenta2654
    @thelawgameplaywithcommenta2654 Год назад +1

    So the event dispatcher just has a reference to the event and so can only "hear" things while interfaces are referring to the interface itself.
    The part I find confusing is the cast since I always hear casting creates a hard reference. Granted the player is already loaded and the cast only works when entity in question spawns so load times should be kept down.

  • @ChrisCohen
    @ChrisCohen Год назад

    I might have missed something here. In your example of adding health, the BP is getting a reference to the player pawn, casting it, then calling an event on that object.
    But if you already have a reference to the player pawn that has been cast to a specific class, you could just call a public method on that class, so isn't that simpler than using the event system?
    I guess what I'm saying is that if you need to find all objects of type (player pawn in this case) and cast them all, what's the advantage of using an event over just calling a method?
    I'd kind of expected to be able to just fire an event from one BP called "X", and then have other BPs subscribe to the "X" event without the two classes needing to know anything else about each other.

    • @GDXR
      @GDXR  Год назад +1

      the other blueprint still needs a refrence to the blueprint with the dispatcher. If your blueprints existi in the level then you can manually point to them with a public varible but in this case i do it this way with the health becasue the player doesnt exhist till the game begings. So I use the cast to find the player after its spawned and store it (This happens only once on start so its not that expensive. From there the bind is just always listening for the event to be fired from that blueprint. And only runs when its fired.

  • @SomunImmersive
    @SomunImmersive 2 года назад +2

    Which is faster / more performant? Interfaces, event dispatchers or dare I say... direct BP communication?

    • @GDXR
      @GDXR  2 года назад +1

      It really depends how you use them, obviously if you have loads of refrences and i meen loads then it will becomes an issue but honestly its neglegable regarding performance. But direct communication like casting more ofet causes issue later down the line.

    • @SomunImmersive
      @SomunImmersive 2 года назад +3

      @@GDXR each has their benefits, but yes over-casting can become problematic. I like to create event dispatchers in the gamemode and then call and assign them where needed

    • @joacotossello
      @joacotossello Год назад +3

      ​@@SomunImmersive IDK if u still doubting this, but:
      -CAST-
      + Casts make a Hard Reference each time u cast, so, that's too RAM expensive if: u do it a lot (like +500k times), Have to cast to a VERY complex actor OR a class that's too deep in an inheritance branch.
      ++ If u cast THE SAME actor more than 1 time, u should set the cast's result as a variable (Cache it).
      ++ If u have to cast an actor that's gonna change it's value very often (e.g. WeatherSystemActor) u should make a By-Ref Var to access that memory location instead of the actor's state snapshot.
      -Interfaces-
      + U won't need to cast anything or set actor's references manually (like in the video), U simply do a "GetAllActorsWithInterface" and that's all.
      // REMEMBER //: That returns an array, if that result is directly a LOOP input, that "GetAllActorsWithInterface" It'll be called EVERY ITERATION. CACHE IT FIRST.
      ++ Interfaces are better than EventDispatchers 'cuz aren't running in the background, u just use interface's functions when u need with no other CPU cost.
      ++ Interfaces can be used with "Observer" pattern. U just implement A receiver system or a sender too... The RECEIVER will be the "Lights" interface and the Sender will be the "LightManager"... E.g. The Manager tell each actor with "Lights" interface to change its color and Each light could tell the Manager "Done".
      -Event Dispatchers-
      + U'll need the sender's reference to access its EventDispatcher, so, "GetActorOfClass" in EVERY receiver would be expensive.
      ++ U could set ALL dispatchers in the GameInstance but that's not clean. Also, U'll need to cast your GameInstance in EVERY receiver and sender...
      IMHO, It all DEPENDS on what u wanna achieve, but, Interfaces are the best solution to almost everything, if u can manage memory references and RAM consumption, U'll have a very clean code and a lot less hard references ('cuz one saves a value [actor and its references] and the other just a POINTER).

    • @user-yx5wd5yy6h
      @user-yx5wd5yy6h Месяц назад +1

      @@joacotossello very good and useful comment

  • @damnfail9316
    @damnfail9316 2 года назад +1

    hi, how do i stop sound from another blueprint?

    • @GDXR
      @GDXR  2 года назад +3

      When you create a sound in another blueprint you will have it saved to a variable. You just need to access that and tell it to stop. how you do it is entirely up to you. with a dispatcher or interface.

  • @GeniusPancake
    @GeniusPancake Год назад

    I just don't like the idea of assigning references trough the editor.... It just feels like I will forget to do it and get many errors. That's why I don't like event dispatchers mutch. I just feel that there is much better way to use them than this. Like, for binding UI to the player trough events or making hotkeys, dialogue system or something.
    Any kind of interaction is so much better with interfaces since I don't have to know about the other object.. at all. If touching the trigger fires up the lights then yeah, use dispatchers but it still looks weird to do so, in my mind. I know that I am most likely wrong but it just looks wrong to use it!

  • @prototypega8257
    @prototypega8257 Год назад

    better question is what is the diffrent to multicast

  • @natemorga
    @natemorga 6 месяцев назад

    Please give me a like for saving everyone 18+ mins of thier LIFE just jump to this point...... BRO DONT BE SO LONG WINDED... 18:50

    • @briankranevitter3114
      @briankranevitter3114 5 месяцев назад

      Dude... The title says "HOW TO USE event dispatchers and how they're different to interfaces".
      You just jumped to the part "how they're different to interfaces", but many people need to know how to use them...

  • @pixelasm
    @pixelasm Год назад

    Thanks for sharing the insights. To me it seems like event dispatchers provide a more flexible and therefore easier setup down the line, or am I missing something? What benefit do interfaces have over event dispatchers?

    • @GDXR
      @GDXR  Год назад

      interfaces are pretty direct communication, dispatchers don't care who is listening. But the listening blueprint will do what it's told.

    • @pixelasm
      @pixelasm Год назад

      @@GDXR Yes indeed I do understand that they do have a different direction of communication. But whilst you have to setup every connection between an interface and the involved actors manually you do not seem to need to do this with an event dispatcher, exactly like you showed in your examples.
      So I wonder if there is any benefit of using an interface over an event dispatcher. (sorry I am rather new to Unreal development and it´s best practices, but I want to learn :)

  • @VisQo-Herold
    @VisQo-Herold Год назад

    Thx! Started with it a while ago, what helps me now is only using get All Actors of Class "BP_.." for the Target of Call "...".