What's the best way to set a state?

What’s, in term of performance, the best way to set a state as in the image?

Hi,

The Set #1 might be slightly faster than Set #2, however, this performance difference here is very very insignificant. First thing to note here is that having that function twice there for different execution branches have no effect whatsoever on the performance of your program. The only difference is that in Set #2 there might be an additional copying for the Rotator struct which is passed by value. However, as I already mentioned this difference is very insignificant! (In fact, the compiler might even optimize that for you). Nowadays computers are extremely powerful and this time of optimizations should be of your least concern (unless you’re frequently copying a heavy object by value!). Overall, feel free to use variables in your blueprints whenever you feel like you need one. It’s always better to have a neat and clean blueprint than an unreadable spaghetti looking one with wires stretching from one side of the screen to another just because you refused to use variables!

The only tip I can give you when working with blueprints is that when you create a function and add input node to it, try passing heavy objects such as strings and structures by reference (You can do that by going into your function, clicking on the input node and from the input list, expand your input and check pass-by-reference. However, you should be careful using it because it is passed by reference and any change to it will be reflected in the original variable.)

Hope this answers your question :slight_smile:

Really thanks. Using blueprint sometimes is hard to understand what is really optimized or not. :slight_smile: