Download

UGameplayStatics::SpawnEmitterAtLocation none of 3 overloads could convert all the argument types

Hey peeps! I’m am getting the above error in the following code.
File:FPSObjectiveActor.cpp



#include "FPSObjectiveActor.h"
#include <Runtime\Engine\Classes\Components\SphereComponent.h>
#include <Runtime\Engine\Classes\Components\StaticMeshComponent.h>
#include <Runtime\Engine\Classes\Particles\ParticleSystemComponent.h>
#include <Kismet\GameplayStatics.h>
// Sets default values
AFPSObjectiveActor::AFPSObjectiveActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
MeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComp"));
MeshComp->SetCollisionEnabled(ECollisionEnabled::NoCollision);


RootComponent = MeshComp;

SphereComp = CreateDefaultSubobject<USphereComponent>(TEXT("SphereComp"));
SphereComp->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
SphereComp->SetCollisionResponseToAllChannels(ECR_Ignore);
SphereComp->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);

SphereComp->SetupAttachment(MeshComp);
}

// Called when the game starts or when spawned
void AFPSObjectiveActor::BeginPlay()
{
Super::BeginPlay();
PlayEffects();
}

void AFPSObjectiveActor::PlayEffects()
{
UGameplayStatics::SpawnEmitterAtLocation(this, PickupFX, GetActorLocation());
}

// Called every frame
void AFPSObjectiveActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);

}

void AFPSObjectiveActor::NotifyActorBeginOverlap(AActor* OtherActor)
{
Super::NotifyActorBeginOverlap(OtherActor);
PlayEffects();
}


File:FPSObjectiveActor.h



#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "FPSObjectiveActor.generated.h"
class USphereComponent;

UCLASS()
class FPSGAME_API AFPSObjectiveActor : public AActor
{
GENERATED_BODY()

public:
// Sets default values for this actor's properties
AFPSObjectiveActor();

protected:
UPROPERTY(EditDefaultsOnly, Category = "Effects")
UParticleSystemComponent* PickupFX;
UPROPERTY(VisibleAnywhere, Category = "Components")
UStaticMeshComponent* MeshComp;
UPROPERTY(VisibleAnywhere, Category = "Components")
USphereComponent* SphereComp;
// Called when the game starts or when spawned
virtual void BeginPlay() override;
void PlayEffects();


public:
// Called every frame
virtual void Tick(float DeltaTime) override;

virtual void NotifyActorBeginOverlap(AActor* OtherActor) override;

};


I get this problem all the time. The overloaded call is actually fine, but the compiler gets confused because it doesn’t know what UParticleSystem* is and mistakes it for a function call argument issue.

If you include the header (ParticleSystem.h) in your CPP file, the warning should go away.

@TheJamsh Same Error Still occurring. I tried adding both header files “ParticleSystem.h” and “ParticleSystemComponent.h” in the CPP file
But nothing’s changed :frowning:

Oh I can see the problem, “PickupFX” should be a UParticleSystem* not a UParticleSystemComponent*

@TheJamsh Thanks!! Now it works.:):wink: