UE5 Understanding Pure Functions - Be a better game dev

Поділитися
Вставка
  • Опубліковано 22 тра 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

КОМЕНТАРІ • 35

  • @danrius98
    @danrius98 3 дні тому +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 4 місяці тому +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!

  • @rky115
    @rky115 4 місяці тому +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.

  • @fencingprincess6537
    @fencingprincess6537 4 місяці тому +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.

  • @vladimirkhadyko8304
    @vladimirkhadyko8304 2 місяці тому +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 4 місяці тому +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 :)

  • @MIKELENZTIPS
    @MIKELENZTIPS 4 місяці тому +1

    Excellent content - 🙌

  • @matka5130
    @matka5130 4 місяці тому +1

    Great, as always

  • @Agachack
    @Agachack 3 місяці тому +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.

  • @shubhamgangwar4165
    @shubhamgangwar4165 4 місяці тому +1

    Changed my view towards pure function 😅

    • @LeafBranchGames
      @LeafBranchGames  4 місяці тому +1

      More knowledge allows for better decisions. :)

  • @gokuvinod2850
    @gokuvinod2850 4 місяці тому +4

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

    • @LeafBranchGames
      @LeafBranchGames  4 місяці тому +1

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

    • @gokuvinod2850
      @gokuvinod2850 4 місяці тому

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

  • @paveldinh1127
    @paveldinh1127 4 місяці тому

    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  4 місяці тому +1

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

  • @MCA-GK
    @MCA-GK 4 місяці тому +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 😲

  • @PixelsLaboratory
    @PixelsLaboratory 4 місяці тому +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  4 місяці тому +3

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

  • @primordial987
    @primordial987 4 місяці тому

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

  • @michaelgroler1336
    @michaelgroler1336 4 місяці тому

    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  4 місяці тому +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.

  • @alexey3203
    @alexey3203 4 місяці тому

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

    • @LeafBranchGames
      @LeafBranchGames  4 місяці тому

      It is mentioned in the video when applicable.