it seems like it says its expecting 3 arguments but the code im using is the same as the tutorial
here is the error
C:\Program Files\Epic Games\UE_5.0EA\Engine\Source\Runtime\CoreUObject\Public\UObject/SparseDelegate.h(362): note: see declaration of 'TSparseDynamicDelegate<FTakeAnyDamageSignature_MCSignature,AActor,FTakeAnyDamageSignatureInfoGetter>::__Internal_AddDynamic'
Building TanksEditor...
Using Visual Studio 2019 14.29.30038 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037) and Windows 10.0.18362.0 SDK (C:\Program Files (x86)\Windows Kits\10).
Building 4 actions with 12 processes...
[1/4] HealthComponent.cpp
C:\GameDev\Tanks\Source\Tanks\Components\HealthComponent.h(31): warning C4263: 'void AHealthComponent::TakeDamage(AActor *,float,const UDamageType *,AController *,AActor *)': member function does not override any base class virtual member function
C:\GameDev\Tanks\Source\Tanks\Components\HealthComponent.h(33): warning C4264: 'float AActor::TakeDamage(float,const FDamageEvent &,AController *,AActor *)': no override available for virtual member function from base 'AActor'; function is hidden
C:\Program Files\Epic Games\UE_5.0EA\Engine\Source\Runtime\Engine\Classes\GameFramework/Actor.h(2975): note: see declaration of 'AActor::TakeDamage'
C:\GameDev\Tanks\Intermediate\Build\Win64\UnrealEditor\Inc\Tanks\HealthComponent.generated.h(11): note: see declaration of 'AActor'
C:\GameDev\Tanks\Source\Tanks\Components\HealthComponent.cpp(23) : error C2653: 'UHealthComponent': is not a class or namespace name
C:\GameDev\Tanks\Source\Tanks\Components\HealthComponent.cpp(23) : error C2276: '&': illegal operation on bound member function expression
C:\GameDev\Tanks\Source\Tanks\Components\HealthComponent.cpp(23) : error C2672: 'TSparseDynamicDelegate<FTakeAnyDamageSignature_MCSignature,AActor,FTakeAnyDamageSignatureInfoGetter>::__Internal_AddDynamic': no matching overloaded function found
C:\GameDev\Tanks\Source\Tanks\Components\HealthComponent.cpp(23) : error C2780: 'void TSparseDynamicDelegate<FTakeAnyDamageSignature_MCSignature,AActor,FTakeAnyDamageSignatureInfoGetter>::__Internal_AddDynamic(UserClass *,TBaseDynamicDelegate<FWeakObjectPtr,RetValType,AActor *,float,const UDamageType *,AController *,AActor *>::TMethodPtrResolver<UserClass>::FMethodPtr,FName)': expects 3 arguments - 2 provided
with
[
RetValType=void
]
here is my health componet cpp and .h
.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Tanks/GameModes/TanksGameModeBase.h"
#include "HealthComponent.generated.h"
UCLASS()
class TANKS_API AHealthComponent : public AActor
{
GENERATED_BODY()
private:
UPROPERTY(EditAnywhere)
float DefaultHealth = 100.f;
float Health = 0.f;
ATanksGameModeBase* GameModeReference;
public:
// Sets default values for this actor's properties
AHealthComponent();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
UFUNCTION()
void TakeDamage(AActor* DamagedActor, float Damage, const UDamageType* DamageType, AController* InstigatedBy, AActor* DamageCauser);
};
.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "HealthComponent.h"
#include "Tanks/GameModes/TanksGameModeBase.h"
#include "Kismet/GameplayStatics.h"
// Sets default values
AHealthComponent::AHealthComponent()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
}
// Called when the game starts or when spawned
void AHealthComponent::BeginPlay()
{
Super::BeginPlay();
Health = DefaultHealth;
GameModeReference = Cast<ATanksGameModeBase>(UGameplayStatics::GetGameMode(GetWorld()));
GetOwner()->OnTakeAnyDamage.AddDynamic(this, &UHealthComponent::TakeDamage);
}
void AHealthComponent::TakeDamage(AActor* DamagedActor, float Damage, const UDamageType* DamageType, AController* InstigatedBy, AActor* DamageCauser)
{
if (Damage == 0) { return; }
Health = FMath::Clamp(Health - Damage, 0.f, DefaultHealth);
if(Health <= 0)
{
if (GameModeReference)
{
GameModeReference->ActorDied(GetOwner());
}
else
{
UE_LOG(LogTemp, Warning, TEXT("No Game Mode Set"));
}
}
}