# How to spawn a particle system

**URL:** <https://forums.unrealengine.com/t/how-to-spawn-a-particle-system/468112>\
**Category:** FX\
**Tags:** fobjectfinder, unreal-engine, question\
**Created:** [July 13, 2020, 5:52pm UTC](https://forums.unrealengine.com/t/how-to-spawn-a-particle-system/468112 "2020-07-13T17:52:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Boutta\_Be\_Banned](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Boutta\_Be\_Banned](https://forums.unrealengine.com/u/Boutta_Be_Banned)\
**Post date:** [July 13, 2020, 5:52pm UTC](https://forums.unrealengine.com/t/how-to-spawn-a-particle-system/468112/1 "2020-07-13T17:52:24Z")

</div>

I am trying to spawn an emitter using the explosion effect given in the starter content folder of UE4. I am trying to use `static ConstructorHelpers::FObjectFinder<UParticleSystem> explosion(TEXT("/Game/FirstPerson/Particles/P_Explosion.P_Explosion"));`

but it gives me the error

G:\UE\_4.24\Engine\Source\Runtime\CoreUObject\Public\UObject/ConstructorHelpers.h(110) : error C2664: ‘void ConstructorHelpers::ValidateObject(UObject \*,const FString &,const TCHAR \*)’: cannot convert argument 1 from ‘T \*’ to ‘UObject \*’

I have tried a lot of different solutions and have researched for hours on end trying to solve this, but I haven’t been able to and so I’d really appreciate it if someone could help me out.

Projectile.h

```
#pragma once

#include "CoreMinimal.h"
#include "ParticleDefinitions.h"
#include "GameFramework/Actor.h"
#include "Runtime/Engine/Classes/Kismet/GameplayStatics.h"
#include "Runtime/Engine/Classes/Kismet/KismetSystemLibrary.h"
#include "FirstShooterProjectile.generated.h"

UCLASS(config=Game)
class AFirstShooterProjectile : public AActor
{
	GENERATED_BODY()

	/** Sphere collision component */
	UPROPERTY(VisibleDefaultsOnly, Category=Projectile)
	class USphereComponent* CollisionComp;

	/** Projectile movement component */
	UPROPERTY(VisibleAnywhere, Category = Movement, meta = (AllowPrivateAccess = "true"))
	class UProjectileMovementComponent* ProjectileMovement;

public:
	AFirstShooterProjectile();
	/** called when projectile hits something */
	UFUNCTION()
	void OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit);

	/ **Returns CollisionComp subobject** /
	FORCEINLINE class USphereComponent* GetCollisionComp() const { return CollisionComp; }
	/ **Returns ProjectileMovement subobject** /
	FORCEINLINE class UProjectileMovementComponent* GetProjectileMovement() const { return ProjectileMovement; }
	void FireInDirection(const FVector& ShootDirection, float rocketCharge);
	UPROPERTY(EditAnywhere)
	UParticleSystem* explosiveSpawn;

	
};

```

Projectile.cpp

```
#include "FirstShooterProjectile.h"
#include "GameFramework/ProjectileMovementComponent.h"
#include "Components/SphereComponent.h"
#include "UObject/ConstructorHelpers.h"
#include "Engine/World.h"
#include "Runtime/Engine/Classes/Kismet/GameplayStatics.h"
#include "Runtime/Engine/Classes/Kismet/KismetSystemLibrary.h"
#include "Runtime/Engine/Classes/Kismet/GameplayStaticsTypes.h"

AFirstShooterProjectile::AFirstShooterProjectile()
{
	
	// Use a sphere as a simple collision representation
	CollisionComp = CreateDefaultSubobject<USphereComponent>(TEXT("SphereComp"));
	CollisionComp->InitSphereRadius(5.0f);
	CollisionComp->BodyInstance.SetCollisionProfileName("Projectile");
	CollisionComp->OnComponentHit.AddDynamic(this, &AFirstShooterProjectile::OnHit); // set up a notification for when this component hits something blocking

	// Players can't walk on it
	CollisionComp->SetWalkableSlopeOverride(FWalkableSlopeOverride(WalkableSlope_Unwalkable, 0.f));
	CollisionComp->CanCharacterStepUpOn = ECB_No;

	// Set as root component
	RootComponent = CollisionComp;

	// Use a ProjectileMovementComponent to govern this projectile's movement
	ProjectileMovement = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("ProjectileComp"));
	ProjectileMovement->UpdatedComponent = CollisionComp;
	ProjectileMovement->bRotationFollowsVelocity = true;
	ProjectileMovement->bShouldBounce = false;
	ProjectileMovement->ProjectileGravityScale = 0;

	// Die after 10 seconds by default
	InitialLifeSpan = 10.0f;
	static ConstructorHelpers::FObjectFinder<UParticleSystem> explosion(TEXT("/Game/FirstPerson/Particles/P_Explosion.P_Explosion"));
	explosiveSpawn = explosion.Object;
	
}

void AFirstShooterProjectile::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
	// Only add impulse and destroy projectile if we hit a physics
	if ((OtherActor != this) && (OtherComp != NULL))
	{	
		//Get World
		UWorld* world = GetWorld();
		FActorSpawnParameters SpawnParams;
		FRotator rotator = Hit.ImpactNormal.Rotation();
		FVector spawnLocation = Hit.ImpactPoint;
		UGameplayStatics::SpawnEmitterAtLocation(world, explosiveSpawn, spawnLocation, rotator, true);

		 
		Destroy();
	}
}

void AFirstShooterProjectile::FireInDirection(const FVector& ShootDirection, float rocketCharge)
{
	ProjectileMovement->Velocity = ShootDirection * (rocketCharge * 10000.0f);
}

I provided the entirety of the files involved in case that helps. This is my first post, so sorry if I'm missing any common practices or formalities.
```

---

<div class="post-metadata">

**Author:** ![irajsb](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/irajsb/32/740687_2.png) [@irajsb](https://forums.unrealengine.com/u/irajsb)\
**Post date:** [July 14, 2020, 7:57am UTC](https://forums.unrealengine.com/t/how-to-spawn-a-particle-system/468112/2 "2020-07-14T07:57:36Z")

</div>

Make a Uproperty (EditAnyWhere) for your effect and make a bp out of your projectile then spawn that bp when weapon fires.

---

<div class="post-metadata">

**Author:** ![EvilCleric](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@EvilCleric](https://forums.unrealengine.com/u/EvilCleric)\
**Post date:** [July 14, 2020, 8:30am UTC](https://forums.unrealengine.com/t/how-to-spawn-a-particle-system/468112/3 "2020-07-14T08:30:55Z")

</div>

In the header:

```
UPROPERTY(EditAnywhere)
class UParticleSystem* explosiveSpawn;

```

In the cpp file:

```
#include "Particles/ParticleSystem.h"
```

---

<div class="post-metadata">

**Author:** ![EvilCleric](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@EvilCleric](https://forums.unrealengine.com/u/EvilCleric)\
**Post date:** [July 14, 2020, 8:36am UTC](https://forums.unrealengine.com/t/how-to-spawn-a-particle-system/468112/4 "2020-07-14T08:36:24Z")

</div>

And don’t forget to always protect your pointers.

---

<div class="post-metadata">

**Author:** ![Boutta\_Be\_Banned](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Boutta\_Be\_Banned](https://forums.unrealengine.com/u/Boutta_Be_Banned)\
**Post date:** [July 14, 2020, 2:07pm UTC](https://forums.unrealengine.com/t/how-to-spawn-a-particle-system/468112/5 "2020-07-14T14:07:29Z")

</div>

Thank you so much!! I had tried doing this one simple thing for so many hours and I can’t believe I just needed these small changes!! I could cry, you’re a solid lad, thanks so much!

---

<div class="post-metadata">

**Author:** ![Boutta\_Be\_Banned](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Boutta\_Be\_Banned](https://forums.unrealengine.com/u/Boutta_Be_Banned)\
**Post date:** [July 14, 2020, 2:08pm UTC](https://forums.unrealengine.com/t/how-to-spawn-a-particle-system/468112/6 "2020-07-14T14:08:09Z")

</div>

The other answer worked out for me, but thanks so much! I appreciate it!
