Hello, I have an actor representing everyone’s favorite starship, AEnterprise. To represent everyone’s favorite weapon on said starship, I have a few APhasers which I’ve attached to the Enterprise via the following code:
void AEnterprise::FirePhasers()
{
ABaseLaserProjectile * Weapon = GetWorld()->SpawnActor<ABaseLaserProjectile>(
ABaseLaserProjectile::StaticClass(),
StaticMeshComponent->GetSocketLocation(FName(TEXT("FireEverything"))),
FRotator(0, 0, 0));
Weapon->AddTickPrerequisiteActor(this);
Weapon->AttachRootComponentTo(
RootComponent,
FName(TEXT("FireEverything")),
EAttachLocation::SnapToTarget,
true);
}
The APhaser’s have a UParticleSystemComponent to represent the beam.
// Create and setup the ParticleSystemComponent
ParticleSystemComponent = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("Particle System"));
// Grab the actual particle effect and attach it
ConstructorHelpers::FObjectFinder<UParticleSystem> PhaserPTSAssetFinder(TEXT("ParticleSystem'/Game/Particles/Phasar.Phasar'"));
if (PhaserPTSAssetFinder.Succeeded()) ParticleSystemComponent->Template = PhaserPTSAssetFinder.Object;
ParticleSystemComponent->bAutoActivate = true;
ParticleSystemComponent->SetHiddenInGame(false);
ParticleSystemComponent->AttachTo(RootComponent);
I’m getting a strange 1-2 frame delay on the position of the particle effect, which is enough to make the beam fire from outside the ship when I change directions.
Any ideas why I’m experiencing the delay or what I can do to fix this?