UE5 Understanding Pure Functions - Be a better game dev

Sdílet
Vložit
  • čas přidán 7. 07. 2024
  • In this episode of be a better game dev, we will be looking into the pure functions.
    Be a better game dev playlist: • Be a better game dev
    Join the Discord server here: / discord
    Support the work of LeafBranchGames on Patreon here: / leafbranchgames

Komentáře • 35

  • @danrius98
    @danrius98 Před měsícem +1

    I encountered bugs because of pure functions so I had my suspicions, but you explained it well and now I have a better understanding, thank you!

  • @emirisik
    @emirisik Před 5 měsíci +8

    I rarely say this - if you're new to the channel, subscribe for sure. There are so many valuable lessons you can take from Leaf's channel!

  • @fencingprincess6537
    @fencingprincess6537 Před 6 měsíci +5

    Thank you so much for taking the time to explain *why* things happen the way they do. This video cleared up some issues that I’d been having and seeing the examples helped a lot.

  • @rky115
    @rky115 Před 5 měsíci +3

    Im pretty new to UE. "studied" the last couple of weeks a ton of informations/tutorials. I love the way you explain stuff. Love the way you do all these examples to clarify it. Keep up the good work sir.

  • @vladimirkhadyko8304
    @vladimirkhadyko8304 Před 4 měsíci +2

    I felt a cold sweat running down my back after the timeline example:) Now I understand why timings were off in some cases...Thank you a lot!

  • @ntjahero
    @ntjahero Před 6 měsíci +2

    Great video, and really good examples you have there. I almost filled my swear jar until I figured why my random calls don’t match as expected :)

  • @matka5130
    @matka5130 Před 6 měsíci +1

    Great, as always

  • @MIKELENZTIPS
    @MIKELENZTIPS Před 6 měsíci +1

    Excellent content - 🙌

  • @shubhamgangwar4165
    @shubhamgangwar4165 Před 5 měsíci +1

    Changed my view towards pure function 😅

  • @gokuvinod2850
    @gokuvinod2850 Před 6 měsíci +4

    i did understand most of the things i'll make sure to check this thanks again sir

    • @LeafBranchGames
      @LeafBranchGames  Před 6 měsíci +1

      The most important thing is to be aware of that they can cause issues in your code if used carelessly. :)

    • @gokuvinod2850
      @gokuvinod2850 Před 6 měsíci

      @@LeafBranchGames yes I'll make sure it's right

  • @Agachack
    @Agachack Před 5 měsíci +1

    Very interresting! I knew the random function, if you do not save the result, gives different numbers each time it is attached to a node, but I did not know if was the case for ALL and BECAUSE of the pure functions! Thanks.

  • @MCA-GK
    @MCA-GK Před 6 měsíci +1

    Oh 😱 man i was having this problems when learning blueprints but my code was strong and i was nowing this issue in blueprint of this type of logics but don't know how they works😊 and you opened my 🧠 like a 😲

  • @primordial987
    @primordial987 Před 5 měsíci

    Pure, if u don't need cache i think.
    For example, random array elem node and shuffle array which not pure.

  • @paveldinh1127
    @paveldinh1127 Před 5 měsíci

    Nice and straight forward explanation. Just one minor detail I'm wondering about Random func. Wouldn't it be simpler just to cache the class with the index into vars and pass it to the next function instead of having index/class to get the other var through get or find ? 9:19

    • @LeafBranchGames
      @LeafBranchGames  Před 5 měsíci +1

      Caching the information will lead to the same error since random is pure.

  • @michaelgroler1336
    @michaelgroler1336 Před 6 měsíci

    Thank you! I got a question about a minor detail probably. When using random, getting the index first and then accessing the object via "get" should be faster than object first and "find"? I am not sure how "find" is implemented but probably best case scenario is O(log n) vs O(1) for "get"?

    • @LeafBranchGames
      @LeafBranchGames  Před 6 měsíci +1

      I am unsure, I have not looked under the hood to see the scalability of the search algorithm that is being used.
      But as a general expectation I believe it would be considerably faster to reach a value from an array using an index rather than making a comparison of the class/object/whatever you have in the array.

  • @PixelsLaboratory
    @PixelsLaboratory Před 5 měsíci +1

    Although I knew this all along about user-made functions, what you did at 05:30 completely blew me away, I could not understand why that was happening for a few minutes, until I realized that the comparison "node" is actually a pure function in itself, right?! Is my understanding correct? Now I'm wondering how many such standard BP math nodes behave like Pure functions. I'm already scared at what bugs I might be having now that I'm looking back at all the times I did something like this without knowing that ALL nodes without an Execution In/Out pin are actually Pure functions, not just user-made functions. Btw, at 11:00 I guess that's what you meant by a new "node", not any node, but one with an Exec line, right?

    • @LeafBranchGames
      @LeafBranchGames  Před 5 měsíci +3

      You are correct. Many nodes are in fact pure functions. So the behavior happens much more often than one might first expect.

  • @alexey3203
    @alexey3203 Před 5 měsíci

    Thank you for the explanation. But is missing the advantages of pure functions or the examles where they can be used