How do I make global static functions exposed to Blueprints?

So I tried creating a custom class based on BP Function Libraries - UBlueprintFunctionLibrary - but no matter what I try, I cannot get my new blueprint class to show up in the editor.

I tried replacing GENERATED_BODY() with GENERATED_UCLASS_BODY() - and using a constructor in in CPP file

  • " UavKep2Cart::UavKep2Cart(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) {}"
  • but I can’t get it to show up even though it compiles fine.

Am I misunderstanding something - or will this method just not work? I really just would like to be able have a blueprint Function which takes simple inputs and calculates a vector position - and I want that calculation to be possible anywhere in the project - since it will be used for reference frame conversion and a lot of static calculations for energy cost, etc.

Are there any good code examples of ways to create globally available BP functions?

Thanks for any help! :slight_smile:

Not sure if you accidentally looked over this link(down below), but just in case here it is.
Can you post a section of the .h and .cpp??

– Paradox

I got C++ functions to show up as blueprint nodes by making them static BlueprintCallable functions. Header code:

class MYGAME_API UGridLibrary : public UObject
	// Geometric calculations
	UFUNCTION(BlueprintCallable, BlueprintPure, Category=MyGame)
	static FVector GridToWorld(const FGridTransform& GridPlacement, const int32 X, const int32 Y);
	UFUNCTION(BlueprintCallable, BlueprintPure, Category=MyGame)
	static void WorldToGrid(const FGridTransform& GridPlacement, const FVector WorldPos, int32& X, int32& Y);


I just realized I’m not inheriting from UBlueprintFunctionLibrary, its probably better if you do. I’m not sure what difference it makes.

Aha - finally - declaring it static worked - but I had to start a fresh project to test it. I’d changed so many things trying to get it to work that I corrupted something.

Also, BlueprintPure needs to be turned on as you’ve shown.

Thanks folks!