[Unreal] c++, blueprint 서로 연동

 // Fill out your copyright notice in the Description page of Project Settings.


#pragma once


#include "CoreMinimal.h"

#include "UObject/Interface.h"

#include "HitInterface.generated.h"


// This class does not need to be modified.

UINTERFACE(MinimalAPI)

class UHitInterface : public UInterface

{

GENERATED_BODY()

};


/**

 * 

 */

class SLASH_API IHitInterface

{

GENERATED_BODY()


// Add interface functions to this class. This is the class that will be inherited to implement this interface.

public:

UFUNCTION(BlueprintNativeEvent)

void GetHit(const FVector& ImpactPoint);

};

- call full c++ code in blueprint (can be called c++ to c++, c++ then blueprint then c++)

- after declaring BlueprintNativeEvent, inherited overrides and implement function body must have '_Implementation' attached.

void ABreakableActor::GetHit_Implementation(const FVector& ImpactPoint)

{

}

HitInterface->Execute_GetHit(BoxHit.GetActor(), BoxHit.ImpactPoint);

(first parameter is the class executing the implemented function)


UCLASS()

class SLASH_API AWeapon : public AItem

{

public:

    UFUNCTION(BlueprintImplementableEvent)

void CreateFields(const FVector& FieldLocation);

}

callblueprint in c++ (no c++ code implented)


UFUNCTION(BlueprintCallable)

void CreateFields(const FVector& FieldLocation);

call c++ code in blueprint




UFUNCTION(BlueprintNativeEvent)

bool traceForPhysicsBodies(AActor*& HitActor, UPrimitiveComponent*& FieldLocation);

- has default c++ implementation

- blueprint can call to super

- doesn't have to be implemented in blueprint

https://www.youtube.com/watch?v=221vG33x5zQ&ab_channel=RGB



댓글

이 블로그의 인기 게시물

[ref game]

[AI Image]