so i am trying to setup a way to tell my NPC class it needs to do things after it has died such as telling the Rally Point that keeps track of NPCs that the npc no longer exists (stupid nullptr) however when I try this I get the error
cannot convert argument 2 from … (void) to … (AActor*) the parts in between are the exact same. Anyone have an idea as to what I am doing wrong / a better way to do this than what I am trying to do
code being used
void ANPC::WhenDestroyed()
{
connectedPoint->RemoveUnit(this, 1);
}
// Sets default values
ANPC::ANPC()
{
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don’t need it.
PrimaryActorTick.bCanEverTick = true;
inventory = CreateDefaultSubobject<UStorage_System>(TEXT(“Inventory”));
AddOwnedComponent(inventory);
inventory->ComponentTags.Add(FName(“Inventory”));
factions = CreateDefaultSubobject(TEXT(“Factions”));
AddOwnedComponent(factions);
name = GetName();
}
// Called when the game starts or when spawned
void ANPC::BeginPlay()
{
Super::BeginPlay();
OnDestroyed.AddDynamic(this, &ANPC::WhenDestroyed);
Where the function MyDestroyed should look like this:
UFUNCTION()
void MyDestroyed(AActor* Act);
As you can see, the MyDestroyed() function now recieves an Actor. However, I did not find out, which actor this is in particular. I guess it’s the destroyed one, but as this function is called in the actor being destroyed, it does not make much sense.
You may add a global function or a function of another class perhaps as on the OnDestroyed event list. Then you’ll want to know in that function which actor was destroyed.
You may add a global function or a function of another class perhaps as on the OnDestroyed event list. Then you’ll want to know in that function which actor was destroyed.