반응형


Ok, got this working so here is an example....

I want to call a blueprint function from C++.

So first I make a blueprint function called CallFunctionTest. (In our game, and we call a player a "Survivor".) It just prints "Survivor Call Function Test" in pink on the console.

Then I have a static blueprint set of functions like this...

The header file is

  1. #include "Kismet/BlueprintFunctionLibrary.h"
  2. #include "TDLSurvivorFastCache.generated.h"
  3. /**
  4. *
  5. */
  6. UCLASS()
  7. class TDL_API UTDLSurvivorFastCache : public UBlueprintFunctionLibrary
  8. {
  9. GENERATED_UCLASS_BODY()
  10. public:
  11. UFUNCTION(BlueprintCallable, Category = TDLSurvivorCache)
  12. static void TestCPPCallToBP(AActor * c);
  13. };

and the cpp file is...

  1. #include "tdl.h"
  2. #include "ConsoleManager.h"
  3. #include "TDLSurvivorFastCache.h"
  4. UTDLSurvivorFastCache::UTDLSurvivorFastCache(const class FObjectInitializer & PCIP)
  5. : Super(PCIP)
  6. {
  7. UE_LOG(TDLLog, Log, TEXT("UTDLSurvivorFastCache"));
  8. }
  9. void UTDLSurvivorFastCache::TestCPPCallToBP(AActor * c)
  10. {
  11. FOutputDeviceNull ar;
  12. c->CallFunctionByNameWithArguments(TEXT("CallFunctionTest"), ar, NULL, true);
  13. }

Then we call the test function from our SurvivorBP blueprint and it calls the function on the SurvivorBP.

Here are the blueprints

alt text

alt text


https://answers.unrealengine.com/questions/116529/call-blueprint-functions-from-c.html?sort=oldest


반응형

+ Recent posts