Implementing the UAISenseConfig_Damage in C++

Hello everyone, i was trying to implement the damage sense in C++ for my ai. While i ve successfully implemented the Sight and Hearing senses when i try to do the same with the damage sense it just does’t work.

This is in the AI Controller .cpp




AEnemyAIC::damage_config = CreateDefaultSubobject<UAISenseConfig_Damage>(TEXT("Damage Config"));

if (AEnemyAIC::damage_config)
{
   AEnemyAIC::damage_config->SetMaxAge(15.0f);
   GetPerceptionComponent()->ConfigureSense(*AEnemyAIC::damage_config);
}


and inside the onUpdate which get called everytime the AI perseption is updated,



for (size_t k = 0; k < info.LastSensedStimuli.Num(); ++k)
{
   FAIStimulus const stim = info.LastSensedStimuli[k];
   bool stim_result = stim.WasSuccessfullySensed();

   if (stim_result)
   {
#if DEBUG_N_LOG
      LOG_FSTRING_FLOAT(*stim.Type.Name.GetPlainNameString(), 2.0f);
      LOG_FSTRING_FLOAT(*stim.GetDebugDescription(), 2.0f);
#endif
   }
   else
   {
#if DEBUG_N_LOG
      LOG_FSTRING_FLOAT(*stim.Type.Name.GetPlainNameString(), 2.0f);
      LOG_FSTRING_FLOAT(*stim.GetDebugDescription(), 2.0f);
#endif
   }


everytime the sight and the hearing are showing correctly when i print them but the damage sense
when i try to print the Name with


LOG_FSTRING_FLOAT(*stim.Type.Name.GetPlainNameString(), 2.0f);

is printing “Invalid”.

and when i try to print the debug description


LOG_FSTRING_FLOAT(*stim.GetDebugDescription(), 2.0f);

it prints “Uninitialized”,

plus everytime the stim.WasSuccessfullySensed() returns false with the damage sense.

So the problem i think is that i need to initialize the sense possibly, but i don’t know how to do that, if anyone has any idea please let me know.

Thank you!

ps. I have setup up my character correctly to register for the damage sense and also when i fire a projectile ( i do that in BP’s) i call the Report Damage Event as i do with the Hearing Sense, and i report the Report Sound Event which works fine.