UE5 Understanding Pure Functions - Be a better game dev
ฝัง
- เผยแพร่เมื่อ 29 ก.ค. 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
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!
That is exxcellent to hear!
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!
Thank you. :)
a effing greed
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.
Thank you very much, appreciate it!
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.
Glad to hear it!
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!
Glad to hear it was informative. :)
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 :)
Thank you!
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
Sometimes things fall into place a bit slower, but they keep to be remembered more in the future when we use it. :)
Great, as always
Thank you!
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.
My pleasure!
Excellent content - 🙌
Thank you. :)
Pure, if u don't need cache i think.
For example, random array elem node and shuffle array which not pure.
i did understand most of the things i'll make sure to check this thanks again sir
The most important thing is to be aware of that they can cause issues in your code if used carelessly. :)
@@LeafBranchGames yes I'll make sure it's right
Changed my view towards pure function 😅
More knowledge allows for better decisions. :)
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
Caching the information will lead to the same error since random is pure.
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 😲
Haha glad to hear it!
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?
You are correct. Many nodes are in fact pure functions. So the behavior happens much more often than one might first expect.
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"?
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.
Thank you for the explanation. But is missing the advantages of pure functions or the examles where they can be used
It is mentioned in the video when applicable.