Announcement

Collapse
No announcement yet.

Problem with using AIPerception's Team Sense

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Problem with using AIPerception's Team Sense

    Hi, I am trying to use AIPerception's Team Sense (additional to Sight and Hearing).

    Now I have the problem that I can't seem to get it working. I already did the following:
    • Added the sense to the AIPerceptionComponent in the AIController; Max Age is 0.0f
    • Added a Stimuli Source Component to the AIController (doesn't work on pawn also), call RegisterSource.. and RegisterSense(UAISense_Team::StaticClass()) (or sth like that) AND in Blueprint override set Auto Register and added Team sense
    • Call UAIPerceptionSystem::OnEvent with custom settings
    • Listener and Broadcaster are both AIControllers with the same GenericTeamId, so sense should be triggered
    But unfortunately I never receive Team Stimulus in OnTargetPerceptionUpdated
    Here is some code:

    Code:
    void AZombieAIController::BroadcastTarget(AActor* Target)
    {
        FAITeamStimulusEvent TeamEvent = FAITeamStimulusEvent(this, Target, Target->GetActorLocation(), 100000.0f);
        UAIPerceptionSystem::OnEvent(GetWorld(), TeamEvent);
    }
    
    ...
    
    if (Stimulus.Type == UAISense::GetSenseID(UAISense_Team::StaticClass()))
    {
         // Never triggered
         SetTargetLocation(Stimulus.StimulusLocation);
    }

    #2

    OnEvent() are declared with template. so, you have to specify your Event Class and SenseClass like below
    Code:
    UAIPerceptionSystem::OnEvent<FAITeamStimulusEvent, FAITeamStimulusEvent::FSenseClass>(GetWorld(), FAITeamStimulusEvent(GetPawn(), InEnemy, InEnemy->GetActorLocation(), TeamEventRange));

    Comment

    Working...
    X