Depending on the situation and the function called, yes it can make a difference, sometimes quite big. In general when it comes to blueprints there is always a small overhead when executing nodes, but most times it’s negligible.
On another note, pure functions get called once for every connection of their output pins, which is important and can make a difference in the result of your function.
Take the following example:
This function will not give you the result you might expect, since the Random Float In Range
node will get executed twice, once for the comparison and the branch, and once for the print string. And since it generates a random number every time it’s run, a different number than the one used in the comparison will be printed. So in this case you need to cache the result like so:
So if you take that into consideration, especially when it comes to some pure functions like for example:
which could potentially be expensive or slow, then it makes sense to cache the result, if you are using it multiple times and it doesn’t change in between.
However, in cases like this:
where you need to access a value that is changed and you need the latest value, then caching won’t help you.
In this example however, it would be more efficient to do this:
than this:
especially because it would have to calculate a vector length twice, which uses a square root, which is a generally expensive function for computers, even though the vector doesn’t change between the
Set Speed
and Set Is Moving
nodes.
In your specific example, the Get Controlled Pawn
function is this:
![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/3/f/73fd37c435c79650bb35754bbf8873f0200df96f.png)
so it’s basically just a getter for the internal variable “Pawn”, so the only price you’re paying is the small overhead of blueprint nodes. But still, be mindful when using pure functions like that, and of course if you are planning to reuse something it’s always better performance wise to cache it, but at the same time you shouldn’t stress too much about it unless it’s the result of an expensive call