UE5 Understanding Pure Functions - Be a better game dev

Поделиться
HTML-код
  • Опубликовано: 1 авг 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

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

  • @danrius98
    @danrius98 2 месяца назад +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 6 месяцев назад +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 6 месяцев назад +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 6 месяцев назад +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 5 месяцев назад +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 6 месяцев назад +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 6 месяцев назад +1

    Great, as always

  • @MIKELENZTIPS
    @MIKELENZTIPS 6 месяцев назад +1

    Excellent content - 🙌

  • @ate800
    @ate800 19 дней назад +1

    Hello great video! At 12:30 you said Get Controller Pawn>Get Actor Location Node will change the vector value that's returned to the Lerp node because the actual character is moving and the Get Actor Location node is being called repeatedly everytime lerp is called. So Get Actor Location keeps being called and keeps getting the new location that the character has moved to. Pure functions get called when their output pin values are required. So as you said we don't need vector values of where the actor is at but just the original vector location. This is right? I think I get it XD! Thanks that last part took me an extra 10 mins lol :C

    • @LeafBranchGames
      @LeafBranchGames  19 дней назад

      Sometimes things fall into place a bit slower, but they keep to be remembered more in the future when we use it. :)

  • @shubhamgangwar4165
    @shubhamgangwar4165 6 месяцев назад +1

    Changed my view towards pure function 😅

    • @LeafBranchGames
      @LeafBranchGames  6 месяцев назад +1

      More knowledge allows for better decisions. :)

  • @gokuvinod2850
    @gokuvinod2850 6 месяцев назад +4

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

    • @LeafBranchGames
      @LeafBranchGames  6 месяцев назад +1

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

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

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

  • @Agachack
    @Agachack 6 месяцев назад +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 6 месяцев назад +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 6 месяцев назад

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

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

    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  6 месяцев назад +1

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

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

    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  6 месяцев назад +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 6 месяцев назад +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  6 месяцев назад +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 6 месяцев назад

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

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

      It is mentioned in the video when applicable.