How to set "Target" when invoking BlueprintCallable Function?

Hello,

I’m trying to call a Function in Class Blueprint but dont know how to set the target to the Instance. I cannot set it to self because the editor will say its not of the same type. (The Blueprint is derived from the C++ Class, shouldn’t this be compatible?)

If I drag the Pin out it allows me to “Promote to Variable” but when i run the Blueprint it will report an Error which says that it is “NONE”.

In my understanding it wants a reference to the Hexgrid object/instance but i dont unterstand how to get that reference in the editor.

(The Blueprint should be multiple times in the level and each should spawn multiple static meshes, every Blueprint is an instance right?)

Thank you!

Is ‘Generate’ the function giving you problems? Where is it defined? In BP or in C++ base class?

Yes i dont know how to set the target on Generate. Its defined in C++ as non static.

UFUNCTION(BlueprintCallable, Category = "Hexgrid")
void generate(TArray<FVector> &out);

If the above BP (bp_hexgrid) is derived from the class in which ‘Generate’ is defined, you should have no problem calling it with a ‘Self’ reference. They should be compatible.
In C++ you’d call a member function like : this->function(); In BP, the ‘Target’ param just tells it which object it should call the function on. Passing ‘self’ is analogous to ‘this’ in C++

try this:
Create a self reference node (right click and type self and you will get ‘Get a reference to self’). Draw a line from it and type ‘generate’, see if the ‘Generate’ function is listed in the context-sensitive listing. If yes, then you should be fine.

One last thin you could try is to cast the self reference to its parent c++ class and try to pass it a self. But I dont think this is needed here.

Thanks! Because of your answer i got some confidence and checked everything again and it turned out the Parent Class was set to Actor instead of my custom class.

If someone else has this problem: you can change the parent class by File->Reparent Blueprint