Hi.
I’m trying to program my custom BlueprintNativeEvent.
My code is:
.h file
#pragma once
#include "Kismet/BlueprintFunctionLibrary.h"
#include "MyBlueprintFunctionLibrary.generated.h"
/**
*
*/
UCLASS()
class UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintNativeEvent, meta = (FriendlyName = "My First Custom Event", CompactNodeTitle = "MyFirstCustomEvent", Keywords = "My First Custom Event"), Category = Events)
FText TakeDmg(int32 Damage);
private:
UFUNCTION(BlueprintPure, meta = (DisplayName = "Hello World2", CompactNodeTitle = "HelloWorld2", Keywords = "String Hello World2"), Category = Game)
static FText HelloWorld2();
};
.cpp file:
#include "Walls.h"
#include "MyBlueprintFunctionLibrary.h"
FText UMyBlueprintFunctionLibrary::HelloWorld2()
{
return FText::FromString("Hello World 2");
}
FText UMyBlueprintFunctionLibrary::TakeDmg_Implementation(int32 Damage)
{
return FText::FromString("Hello TakeDmg_Implementation");
}
After compilation I can find BlueprintPure HelloWorld2
http://s6.postimg.org/up1tn08s1/screenshot_122.png
…But I can’t find BlueprintNativeEvent MyFirstCustomEvent :
http://s6.postimg.org/5x27frrld/screenshot_123.png
What I do wrong?
I need to implement in C++ some Events, like “On mouse Move” and “Ctrl+Z”…
Solution found here: [link text][1]
As result, my new code is:
#pragma once
#include "GameFramework/PlayerController.h"
#include "MyPlayerController.generated.h"
/**
*
*/
UCLASS()
class WALLS_API AMyPlayerController : public APlayerController
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintNativeEvent)
FText Foo();
UFUNCTION(BlueprintNativeEvent)
FText FooOneParam(float MyFloat);
/** Player's Health is Currently Above 50! Returns
player's exact current health for convenience. This
function runs every tick that the player's health
is high enough! Play healthy sounds here. */
UFUNCTION(BlueprintImplementableEvent, meta = (FriendlyName = "Player Health ~ Player Is Healthy Tick"))
virtual void PlayerIsHealthyTick(float CurrentHealth);
void PlayerTick(float DeltaTime);
};
and .h file
#include "Walls.h"
#include "MyPlayerController.h"
FText AMyPlayerController::Foo_Implementation()
{
return FText::FromString("Hello Foo_Implementation");
}
FText AMyPlayerController::FooOneParam_Implementation(float MyFloat)
{
return FText::FromString("Hello FooOneParam_Implementation");
}
void AMyPlayerController::PlayerTick(float DeltaTime)
{
Super::PlayerTick(DeltaTime);
//========================
// BP Interface
if (this->IsInputKeyDown(EKeys::LeftShift))
{
if (this->IsInputKeyDown(EKeys::E))
{
this->PlayerIsHealthyTick(75);
}
}
//========================
}
After that create BluePrint Class from your C++ class
http://s6.postimg.org/qhc3bddo1/screenshot_125.png
After that in new created BluePrint Class Event Player Health will be accessible:
http://s6.postimg.org/rxnltigkx/screenshot_128.png
SyMutex
(SyMutex)
June 9, 2015, 1:51pm
3
Have you tried searching for “Take Dmg” instead of “My First Custom Event”?