Hello everyone! Can you help me with the problem. I use the C++ interface and call a number of functions on behalf of the character from all Actors who have such an interface. According to the task, I have to call the damage function for actors from them. I just have to have different damage values and that’s it. I’m trying to use TakeDamage, but he needs a special event so that he understands what type I’m probably using. I have an error on FDamageEvent ToDamageEvent
“cannot convert to incomplete class FDamageEvent”
In the task, I should not use anything other than the damage call function. Line Tracing cannot be used. I just have to make a massive appeal to all the actors and call them functions that cause damage.
I started learning C++ for Unreal Engine at the beginning of this year, so the question may seem very stupid.
// Actor_One.h file
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MyInterface.h"
#include "Actor_One.generated.h"
UCLASS()
class THIRDPERSONMP_API AActor_One : public AActor, public IMyInterface
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AActor_One();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
virtual float TakeDamage(float DamageAmount, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, AActor* DamageCauser) override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
// Interface system
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Gameplay")
void SmallHitInteract();
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Gameplay")
void BigHitInteract();
void SmallHitInteract_Implementation() override;
void BigHitInteract_Implementation() override;
};
// Actor_One.cpp file
#include "Actor_One.h"
#include "Engine/EngineTypes.h"
// Sets default values
AActor_One::AActor_One()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void AActor_One::BeginPlay()
{
Super::BeginPlay();
}
float AActor_One::TakeDamage(float DamageAmount, FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser)
{
return Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);
}
// Called every frame
void AActor_One::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void AActor_One::SmallHitInteract_Implementation()
{
AActor* Owner = GetOwner();
float Damage = 10.0f;
if (Owner) {
FDamageEvent ToDamageEvent();
Owner->TakeDamage(Damage, ToDamageEvent, GetOwner()->GetInstigatorController(), this);
}
}
void AActor_One::BigHitInteract_Implementation()
{
AActor* Owner = GetOwner();
float Damage = 20.0f;
if (Owner) {
}
}