Linking a Function to a Variable in Unreal - Rep Notify

Поділитися
Вставка
  • Опубліковано 8 лис 2024

КОМЕНТАРІ • 27

  • @blacktecno
    @blacktecno 3 місяці тому +2

    A great way to get it to update bars without setting up a bind that is constantly checking every frame. Such a gem of a video. Most tutorials for health or score or things as such use binding and that might work for one thing, but as you add up... Anyway, here's a comment for engagement and a like, keep it up!

    • @thegamedevcave
      @thegamedevcave  3 місяці тому

      best way is to make sure you set up a normal function to update your health, and then have that function also update your widget instead. but this is a good thing to keep in mind as a backup solution in case you didn't do that and you already have a bunch of code in place that would be tedious to redo :)

  • @Angry_Karakuri
    @Angry_Karakuri 3 місяці тому

    Thanks, this showed up in my recommendations just now. I did mess around with this before but one thing to note: Structs can't be picked up with this. I mainly wanted to implement this for a config menu but structs aren't picked up. Maybe that's something we'll see in the future but if you're looking for this, don't waste your time trying to get it to work. It doesn't. lol

  • @StudioVacant
    @StudioVacant 3 місяці тому

    this is a sweet trick man, i been wondering about it since ive been working more with the notifys for a multiplayer game. but good to know lol thank you

  • @GreyManFaustus
    @GreyManFaustus 3 місяці тому +3

    This is one of those times where I could have saved a lot of time if I had known earlier.

    • @thegamedevcave
      @thegamedevcave  3 місяці тому

      Little disclaimer, in general it is better to just set up a function to change a variable value and update the value through that and then in that function also do whatever else needs to be done. But this method (while not it’s intended use) can also serve to fill the gaps in code that wasn’t written well from the start. If you’re starting off clean, making proper functions and using those instead is better

  • @ehabelbadry2313
    @ehabelbadry2313 3 місяці тому

    oh wow that's brilliant actually, I'm making a Multiplayer Game but It didn't cross my mind to use this with none replicated variables as well. definitely gonne be useful

    • @thegamedevcave
      @thegamedevcave  3 місяці тому

      if you're in a position to just make a function to update a variable and then just also make that function run other code instead of using this method, that is a better way to do it though, this is just one of those " good to know" methods mainly useful if you want to retroactively change some behavior around a variable :)

    • @ehabelbadry2313
      @ehabelbadry2313 3 місяці тому

      @@thegamedevcave
      brilliant, thank you!

  • @flymacseamus3474
    @flymacseamus3474 3 місяці тому +2

    Thing that worries me a bit with this kind of hack, is how long will this actually work until Epic decides that sending RepNotify without a server is kinda dirty, and so chooses to plug that hole

    • @thegamedevcave
      @thegamedevcave  3 місяці тому +2

      I understand that. I don’t think it’ll be an issue, as far as I understand the way unreal works is that it more or less always runs like server and client but with just a singleplayer game that both of those just exists on the same machine (which is why the host client in a listener server will generally seem to work without replication code even). So if they were to make changes to it I think they would be pretty fundamental changes.
      Of course that’s just my rough guess and I am not sure either. Best not to rely on this kinda thing but good to know about!

    • @flymacseamus3474
      @flymacseamus3474 3 місяці тому

      @@thegamedevcave Actually I didn't know unreal assumes a sort of Client/Server behavior by default, that's interesting to know -- thanks

    • @ryanjdevlin87
      @ryanjdevlin87 3 місяці тому +1

      no you wont have to worry about that, unreal is always running a single player server basically. also the real power of this is in combination w/ event dispatchers to be able to essentially update any numbers of actors with the change . Great video

  • @GiulianoVenturo
    @GiulianoVenturo 3 місяці тому

    when I need to update something in the UI I just make a player ref (on being play) and then bind the value I need and in the function that is created because of the bind I just get the player ref and take the value I need, so whenever the value updates also updates the UI.
    EDIT: I think it's almost the same as use tick event I think but I think that how that works (or at least I hope that how it works xD)

    • @thegamedevcave
      @thegamedevcave  3 місяці тому

      Event tick will force try to update the value every frame even if there is no change. If you have that everywhere that does add up on preformance cost

    • @GiulianoVenturo
      @GiulianoVenturo 3 місяці тому

      @@thegamedevcave yeah kinda sucks but I mean how else would that work? I mean the "Blind" options under the details panel in the widget bp, I thought that's how you normally used it

  • @mangarookie
    @mangarookie 3 місяці тому

    did you try a packaged "shipping" game? does this require any additional setup like server etc. ? sorry if the question is stupid. I just don't know anything about replication and so I don't know if this can messup... But it definitely would speed up and simplify production

    • @ryanjdevlin87
      @ryanjdevlin87 3 місяці тому

      yes it works in packaged games.

  • @88FlyingHigh88
    @88FlyingHigh88 3 місяці тому

    How does this compare to Event Dispatchers?

    • @thegamedevcave
      @thegamedevcave  3 місяці тому

      I suppose it’s kind of similar in some ways, although an event dispatcher usually will call out, and then *other* objects who are listening for that will run a function.

    • @88FlyingHigh88
      @88FlyingHigh88 3 місяці тому

      @@thegamedevcave It was too broad of a question, I was just trying to think of when I'd use a Rep Notify variable over an Event Dispatcher for updating health. I'm not aware of the efficiency difference between the two.

    • @thegamedevcave
      @thegamedevcave  3 місяці тому

      @@88FlyingHigh88 repnorify usually is used for network replication where it actually serves a purpose, for singleplayer games this little trick is only useful if you retroactively want to add some functionality linked to a variable. if you're designing your code well from the start, you'd have a function to update your variables anyway and neither repnotify nor event dispatchers should be needed to get this result :)
      this is just a little trick to keep in mind that might save you having to replace lots of variable setting nodes if you figure out you need to add functionality later down the line.
      Event dispatchers really are something else altogether. those you would put in the function that updates your health to call out to any other objects that are listening out for it.

  • @Phraxas52
    @Phraxas52 3 місяці тому

    How does this affect performance when used heavily on many, many objects in a single player game?
    Seems like a super easy way to set up a delegate. Almost too good to be true kind of super easy..

    • @thegamedevcave
      @thegamedevcave  3 місяці тому +1

      it might technically have a bit of extra overhead over just setting up a function to update your variable that also has all the other stuff that needs to be done (which, to be clear.. is the way you should do this if you can!).
      but i dont think enough to reasonably notice it in a game.

    • @Phraxas52
      @Phraxas52 3 місяці тому +1

      @@thegamedevcave At the very least, it seems like a good little shortcut for fast-iteration prototyping.

  • @powerpc6037
    @powerpc6037 3 місяці тому

    Doesn't this create some kind of overhead and cost extra performance? Why not simply put the widget update stuff in a function and call that after you modified the health value?

    • @thegamedevcave
      @thegamedevcave  3 місяці тому

      That certainly is better! Preformance overhead isn’t really an issue with this but it’s better practice to just update with a function instead anyway. This is mostly useful as a hack to retrofit existing code that doesn’t do that