Hi everyone,
I’m looking to call a blueprint function from python.
Whilst we wait for a direct interface to blueprint functions, I’m using a C++ declaration of my function with BlueprintImplementableEvent
, which is then overridden by the blueprint and called from python:
Not important: My function implementation
Important: My function declaration
UFUNCTION(BlueprintImplementableEvent)
bool clearSpline();
Important: My python function call
unreal.planeTrackEditableWrapper.add_new_point(actor, unreal.Vector(0))
I know that my BlueprintImplementableEvent is written correctly, as calling it from C++ prints “CLEAR SPLINE” onto the screen.
However, when called from python, no string is printed, and the function always returns False.
I understand this is a bit of a complicated one, so any help is very much appreciated.
As a side note, huge thanks to Alex Quevillon for his tutorial: How to call a C++ function using Python
Correction:
Important: My python function call
unreal.planeTrackEditableWrapper.clear_spline(actor)
I should also have mentioned that “planeTrackEditableWrapper” is the name of the C++ Class where the function is declared, and the parent to the blueprint class.
Managed to solve this one by myself;
In order to call a C++ function from python, it must be implemented as a BlueprintCallable
.
You cannot implement a function as both BlueprintCallable
and BlueprintImplementableEvent
for obvious reasons.
(though i did try anyway, and no, it did not work)
So, the solution is to make another C++ function with UFUNCTION(BlueprintCallable)
, with the sole purpose of calling your BlueprintImplementableEvent
.
.h
.cpp
Because of this behaviour, I wonder if using BlueprintImplementableEvent
would allow you to overload a C++ function in python…? Interesting, might look into it later.