Download

How to call a function which is declared in Blueprint from C++?

How to call a function which is declared in Blueprint from C++?

Hm, why would you want to do that? Can you, please, give more details on your situation?

The designer created a function in blueprint.When i finished doing something in c++,i wanted to call that function to inform him of something.

I think it really would be better the other way around. You can have a base C++ function which designer can then override in blueprints to add his custom logic, calling the parent function before-hand (or afterwards, depends on the situation).

You can use BlueprintImplementableEvent.

Declare your function in the base class,Like:

UFUNCTION(BlueprintImplementableEvent)
void SendMessage(FString message);

Call this function whenever you want to send the message to your desinger.

And for designers: Create a BP that inherits the C++ base class you have write and just add new nodes after the “Event SendMessage” in the BP Event Graph.

That’s done.

Long story short, you can’t. C++ Can’t read back functions you’ve created in Blueprint.

As Psycracker says however, you can create a custom Blueprint Event in C++, and then call that event in C++. Hook it up to the desired functionality in Blueprint and you’re away. I personally recommend steering away from this where possible, just because its a confusing workflow IMO.

I have not tried it myself and don’t have access to my testing project right now but could you possibly use the Object->FindFunction(FunctionFName) method to do this? I don’t know if the blueprint function is accessible this way though. Just a thought.