Hey! I am trying to get some barrel smoke into my game. What I have done is I am trying to spawn a particle at the same location where the projectile spawns. The problem is that for some reason, the particle seems to spawn in the middle of the level (always, it never changes spawn location). Anyone know why this could happen? The code worked perfectly earlier on when I was testing it. Highly appreciate any useful answers or input!
const FRotator SpawnRotation = GetControlRotation();
// MuzzleOffset is in camera space, so transform it to world space before offsetting from the character location to find the final muzzle position
const FVector SpawnLocation = GetActorLocation() + SpawnRotation.RotateVector(GunOffset);
UWorld* const World = GetWorld();
if (World != NULL)
{
wpAmmo--;
FString debugAmmo = FString::FromInt(wpAmmo);
if (SmokeClass != NULL)
{
World->SpawnActor<AOneShotParticle>(SmokeClass, SpawnLocation, SpawnRotation);
}
// spawn the projectile at the muzzle
World->SpawnActor<AInstinctProjectile>(ProjectileClass, SpawnLocation, SpawnRotation);
GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Black, debugAmmo);
}