So I am trying to pass a function to another function, similair to the FTimerManager.SetTimer.
I just can’t get it to work. I have looked a little into TFunction and TFunctionRef, but I couldn’t find good enough sources for me. Lamdba’s could be another way to go I heard, but I also have heard of function pointers.
Where do I start? And where are good sources/examples.
I am fine with only taking void functions with no parameters. As for why I am trying to do this, I am trying to expose some of the multithreading capabilities to blueprints.
TFunction works like std::function in normal C++ therefore, “void” is the function’s return type and anything inside the ( ) is the parameters, which can be left empty.
TFunction can’t be a parameter in a UFUNCTION() so keep that in mind.
A simpler way to use function pointers is with a typedef. There is a great tutorial which I link below:
You could add a 2nd function which will be a UFUNCTION() and pass it the return value of your TFunction and use that 2nd function to expose the value in BP. Other than that, yes delegates are a bit more complex but it is the way unreal adds function calls on runtime.