[c++]Add blueprint function to Character class

Hi!

So, i need to add a special function which, depending on the object name returns other values.
And there is a problem.

How can i create a UFUNCTION which is BlueprintCallable in MyCharacter blueprint?

Hey MRCookie-

Using the BlueprintCallable specifier inside the UFUNCTION macro will allow the function to be called inside a blueprint based on that class.

Cheers

Yes, i know that :slight_smile:
I wanted that my function was callable in every blueprint, but here was a little problem. When i was creating funtion in other blueprint, target was always pointing to my default class.

Problem solved by placing “static” before function type.
For example:

 UFUNCTION(BlueprintCallable, Category = "System")
		static uint8 GetObjectName(FString object);

And “target” pin is gone :slight_smile:

Cheers, Cookie

Alright, I have same problem again.
I’ve tried to create a static function, but in this case, i have to get some UPROPERTY values (WidgetTemplate) from my class and when i trying to compile:

Error	2	error C2597: illegal reference to non-static member 'AMainPlayerController::WidgetTemplate

Thanks for advance!

Hey MRCookie-

What does the function you’re using look like as far as the declaration and definition? Is the WidgetTemplate an input parameter or the return value? Please provide additional information for what you’re trying to accomplish.

Cheers

I’ve solved it :slight_smile:

All i had to do was add an AActor* input to my static function and then

Your_Class* PtrToAnActor = NULL;
PtrToAnActor = Cast<Your_Class>(Your_Input);

… and at this point I was able to access all properties, e.g.:

PtrToAnActor->Some_Property = Some_Value

I’ve solved it myself :slight_smile:

All i had to do was add an AActor* input to my static function and then

Your_Class* PtrToAnActor = NULL;
PtrToAnActor = Cast<Your_Class>(Your_Input);

… and at this point I was able to access all properties, e.g.:

PtrToAnActor->Some_Property = Some_Value

Cheers, Cookie