Shooting with NiagaraSystem

Hey Guys!

I am using UE 4.26 and I am trying to use the Niagara System with my gunfire function.

ATM my gun is shooting and I am getting damaged, but my Niagara FX is shooting the opposite way.

When I replace the Niagara system with a particle system instead, it works perfectly.

So basically, my shooter AI is shooting and the result is that I’m getting damaged but the Niagara System is going the opposite way. Can you guys help me?

Here is my code;

void AEnemyShooterCharacter::Fire()
{
//Trace the world, from the eyes of the pawn to crosshairs location
AActor* MyOwner = GetOwner();

if (MyOwner) {
	FVector EyeLocation;
	FRotator EyeRotation;

	MyOwner->GetActorEyesViewPoint(EyeLocation, EyeRotation);

	FVector ShotDirection = EyeRotation.Vector();

	float HalfRad = FMath::DegreesToRadians(BulletSpread);
	ShotDirection = FMath::VRandCone(ShotDirection, HalfRad, HalfRad);

	FVector TraceEnd = EyeLocation + (ShotDirection * 10000);

	FCollisionQueryParams QueryParams;
	QueryParams.AddIgnoredActor(MyOwner);
	QueryParams.AddIgnoredActor(this);
	QueryParams.AddIgnoredActor(Item);
	QueryParams.bTraceComplex = true;
	QueryParams.bReturnPhysicalMaterial = true;

	//Particle "Target" parameter
	FVector TracerEndPoint = TraceEnd;

	FHitResult Hit;
	if (GetWorld()->LineTraceSingleByChannel(Hit, EyeLocation, TraceEnd, Collision_Weapon, QueryParams)) {
		//Blocking hit! Process damage
		AActor* HitActor = Hit.GetActor();

		if (HitActor == nullptr) return;
		//damage
		/* MyOwner*/
		UGameplayStatics::ApplyPointDamage(HitActor, BaseDamage, ShotDirection, Hit, EnemyController, this, UDamageType::StaticClass());

		UE_LOG(LogTemp, Warning, TEXT("Enemy is firing"));

		TracerEndPoint = Hit.ImpactPoint;

	//	PlayFireEffects(TracerEndPoint);
		if (MuzzleEffect) {
			UGameplayStatics::SpawnEmitterAttached(MuzzleEffect, CurrentWeapon->GetItemMesh(), MuzzleSocketName);
		}
		if (BeamParticles) {
			FVector MuzzleLocation = CurrentWeapon->GetItemMesh()->GetSocketLocation(MuzzleSocketName);

				UNiagaraComponent* TracerComp = UNiagaraFunctionLibrary::SpawnSystemAtLocation(GetWorld(), BeamParticles, MuzzleLocation);

				if (TracerComp) {
					TracerComp->SetVectorParameter(TracerTargetName, TraceEnd);
				}
		}

		if (OnShootingSound) UGameplayStatics::PlaySound2D(this, OnShootingSound);
		LastFireTime = GetWorld()->TimeSeconds;
	}
}

}