SpawnActor won't work

Hello!

I am trying to spawn a particle system when a projectile collides, but it won’t work; it doesn’t like the arguments.

Here’s my code:
In .h:


UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = Rendering)
	class UParticleSystem* OnHitPS;

In .cpp:



void ARSGameProjectile::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
	UParticleSystem* ps = OtherActor->GetWorld()->SpawnActor<UParticleSystem>(OnHitPS,this->GetActorLocation());
}

And here is my error:



Info Creating makefile for hot reloading RSGame (working set of source files changed)
Info Compiling game modules for hot reload
Info Parsing headers for RSGameEditor
Info   Running UnrealHeaderTool "C:\Users\Edwin\Documents\Unreal Projects\RSGame\RSGame.uproject" "C:\Users\Edwin\Documents\Unreal Projects\RSGame\Intermediate\Build\Win64\RSGameEditor\Development\RSGameEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
Info Reflection code generated for RSGameEditor in 2.295565 seconds
Info Performing 2 actions (4 in parallel)
Info RSGameProjectile.cpp
Error C:\Users\Edwin\Documents\Unreal Projects\RSGame\Source\RSGame\RSGameProjectile.cpp(42) : error C2664: 'T *UWorld::SpawnActor<UParticleSystem>(UClass *,const FTransform &,const FActorSpawnParameters &)': cannot convert argument 1 from 'UParticleSystem *' to 'const FVector &'
Info         with
Info         
Info             T=UParticleSystem
Info         ]
Error C:\Users\Edwin\Documents\Unreal Projects\RSGame\Source\RSGame\RSGameProjectile.cpp(42) : note: Reason: cannot convert from 'UParticleSystem *' to 'const FVector'
Error C:\Users\Edwin\Documents\Unreal Projects\RSGame\Source\RSGame\RSGameProjectile.cpp(42) : note: No constructor could take the source type, or constructor overload resolution was ambiguous
Info ERROR: UBT ERROR: Failed to produce item: C:\Users\Edwin\Documents\Unreal Projects\RSGame\Binaries\Win64\UE4Editor-RSGame-8693.dll
Info Total build time: 4.37 seconds



What am i doing wrong?

UParticleSystem is not an actor so you can’t use SpawnActor to instantiate it.
You should use this :


UGameplayStatics::SpawnEmitterAtLocation(this,OnHitPS, GetActorLocation(), GetActorRotation(), true);