Download

ue4 custom functions in c++

Hi,
I just start learning c++ in ue4 and have quastion I found tutorial how create custom function and call it in exist blueprint, so i copy this code and some functions this code return errors for example getactorlocation(), i need add some #include in .ccp and .h file?

still not working some problem with InChar

GarnerP57 thx I I appreciate your time, becouse find solution in internet is very hard. Why coding in c++ this engine is so hard I try made ultra simple function and every step I got error. After when you add me solution i was error target so i find i must add static void, now when everything should be fine I have ue4 crash to descop after start play wtf?
MyBlueprintFunctionLibrary.cpp

#include “MyBlueprintFunctionLibrary.h”
#include “GameFramework/Character.h”

void UMyBlueprintFunctionLibrary::MyFunction(ACharacter * InChar, FVector & out)
{
FVector vector = InChar->GetActorForwardVector();
out = vector;
}

MyBlueprintFunctionLibrary.h

#include “CoreMinimal.h”
#include “Kismet/BlueprintFunctionLibrary.h”
#include “MyBlueprintFunctionLibrary.generated.h”

UCLASS()
class MYPROJECT1_API UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()

    UFUNCTION(BlueprintCallable, Category = "Character")
    static void MyFunction(ACharacter* InChar, FVector& out);

};