Announcement

Collapse
No announcement yet.

OnPerceptionUpdated.AddDynamic no instance of function template matches the argument list.

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

    OnPerceptionUpdated.AddDynamic no instance of function template matches the argument list.

    I recently upgraded to UE4.22 and now i am getting an error in my code. The error comes from the the line:
    GetPerceptionComponent()->OnPerceptionUpdated.AddDynamic(this, &AAIController_Wolf::OnPawnDetected);

    Now i am getting the error "no instance of function template matches the argument list.". I cannot figure out what is going on.

    // Fill out your copyright notice in the Description page of Project Settings.


    #include "AIController_Wolf.h"
    #include "Character_Wolf.h"
    #include "Perception/AIPerceptionComponent.h"
    #include "Perception/AISenseConfig_Sight.h"

    //Constructor
    AAIController_Wolf::AAIController_Wolf()
    {

    }

    void AAIController_Wolf::BeginPlay()
    {
    Super::BeginPlay();
    if (GetAIPerceptionComponent() != nullptr)
    {

    UE_LOG(LogTemp, Warning, TEXT("All Systems Set"));
    }
    else
    {
    UE_LOG(LogTemp, Warning, TEXT("Error setting perception component"));

    }
    }

    /*void AAIController_Wolf::Possess(APawn * Pawn)
    {
    Super::Possess(Pawn);
    }
    */
    void AAIController_Wolf::Tick(float DeltaSeconds)
    {
    Super::Tick(DeltaSeconds);
    FVector targetLocation;
    ACharacter_Wolf* character = Cast<ACharacter_Wolf>(GetPawn());

    if (target != NULL)
    {
    targetLocation = GetTargetLocation(target);
    }
    else
    {
    emenyDetected = false;
    }

    if (emenyDetected)
    {
    //Get the direction this controller is facing
    FVector focalPoint = GetFocalPoint();

    //Subtract that direction from the targets location
    FVector direction = focalPoint - targetLocation;

    //Save this direction in a rotation variable
    FRotator newRotation = direction.Rotation();

    //clamp the angle so it is a valid angle
    newRotation.Yaw = FRotator::ClampAxis(newRotation.Yaw);

    SetControlRotation(newRotation);

    character->FaceRotation(newRotation, DeltaSeconds);
    }
    }

    FRotator AAIController_Wolf::GetControlRotation() const
    {
    if (GetPawn() == nullptr)
    {
    return FRotator(0.0f, 0.0f, 0.0f);
    }
    //Yaw is rotation around the up axis (around Z axis), Running in circles 0=East, +North, -South.
    return FRotator(0.0f, GetPawn()->GetActorRotation().Yaw, 0.0f);
    }

    void AAIController_Wolf::OnPawnDetected(TArray<AActor*> Detectedpawns)
    {

    emenyDetected = true;
    target = Detectedpawns[0];
    PrimaryActorTick.bCanEverTick = true;

    SightConfig = CreateDefaultSubobject<UAISenseConfig_Sight>(TEXT("Sight Config"));
    SetPerceptionComponent(*CreateDefaultSubobject<UAIPerceptionComponent>(TEXT("Perception Component")));
    //PerceptionComponent = CreateDefaultSubobject<UAIPerceptionComponent>(TEXT("Perception Component"));


    //Sets how far we can see, when we lose sight, the angle at which we can see, and how long we can see
    SightConfig->SightRadius = AISightRadius;
    SightConfig->LoseSightRadius = AILoseSightRadius;
    SightConfig->PeripheralVisionAngleDegrees = AIFieldOfView;
    SightConfig->SetMaxAge(AISightAge);

    //we can detect, by affliliation, friendles, enemies, and neutrals.
    SightConfig->DetectionByAffiliation.bDetectEnemies = false;
    SightConfig->DetectionByAffiliation.bDetectFriendlies = false;
    SightConfig->DetectionByAffiliation.bDetectNeutrals = false;

    //Set the dominant sense as sight
    GetPerceptionComponent()->SetDominantSense(*SightConfig->GetSenseImplementation());
    GetPerceptionComponent()->OnPerceptionUpdated.AddDynamic(this, &AAIController_Wolf::OnPawnDetected);
    GetPerceptionComponent()->ConfigureSense(*SightConfig);

    }

    #2
    This sounds familiar...

    A quick look at the delegate :
    Code:
    DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FPerceptionUpdatedDelegate, const TArray<AActor*>&, UpdatedActors);
    Your parameter is just a TArray.
    The delegates is a a const TArray.
    Guessing that is the change
    Rule#21: Be polite, be professional, but have a plan to kill everyone you meet.

    Comment

    Working...
    X