Events doesn't appear to other classes

.h :

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnDeath);

FOnDeath OnDeath;

.ccp :
OnDeath.Broadcast();

in Listener OnDeath doesn’t appear and if Ignore its doesn’t appear and write the code :

GetOwner()->OnDeath.AddUniqueDynamic(this, &UDamageSystem::test)

I receive this error :

CompilerResultsLog: f:\MyGame(shoot em up )\MyGame(shoot em up ) 4.19\ShootEmUp\Source\ShootEmUp\DamageSystem.cpp(24): error C2039: 'OnDeath': is not a member of 'AActor'

279140-dhfgjfgj.jpg

the interesting thing is the exact same thing in other project work perfectly!
plz HELP.

GetOwner() return AActor pointer which does not have your delegate declered, i gonna call your class where you declered it ASomething. You need to cast it to your type:

Cast<ASomething>(GetOwner())->OnDeath.AddUniqueDynamic(this, &UDamageSystem::test);

You need to remeber that Cast will return null pointer if owner is not compatible with ASomething, or else you 100% sure that GetOwner is always gonna retunr ASomething object in AActor pointer, you need to do null check. If you would got null pointer then you would have a crash.

ASomething* Owner = Cast<ASomething>(GetOwner());

if(Owner) {
        Owner->OnDeath.AddUniqueDynamic(this, &UDamageSystem::test);
}

Thx SW , my mistake was I getting the meaning of events totally wrong. your reply helped me.