Hello,
I have just started learning UE4, and coming from Unity the transition isn’t half bad
I am attempting to develop a small benchmarking application, if you will.
I have opened the default starting project, First Person Shooter template in Code.
I have altered the needed FPSProjectile header and code to include the following:
FPSTestProjectile.h:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Projectile)
class UParticleSystemComponent* Particles;
FPSTestProjectile.cpp, within AFPSTestProjectile constructor:
//Particles!
Particles = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("Particles"));
Particles->SetRelativeLocation(FVector::ZeroVector);
Particles->AttachTo(RootComponent);
static ConstructorHelpers::FObjectFinder<UParticleSystem> ParticlesInAssets(TEXT("ParticleSystem'/Game/FirstPerson/Particles/P_OrbGlowLights2.P_OrbGlowLights2'"));
Particles->SetTemplate(ParticlesInAssets.Object);
The goal is to have a fancy particle system following the projectile.
I have created a neat particle system like the ones seen in early preview tech demos (lots of swirly random particles around a sphere) using a vector field I obtained from the ParticleEffects demo scene.
Now, as the particle system component is a subobject of the TestProjectile, one would normally assume it would follow it. However this is where wierd stuff starts happening:
In editor, dragging and dropping the TestProjectile into the scene produces expected results - particles are emitted and are following the projectile etc etc.
However as soon as the gameplay mode, or simulate mode is engaged, the particle system always goes to the absolute 0,0,0 coordinates of the world, regardless of it’s parent’s location, or velocity.
Here is where it gets even weirder:
Ejecting from the character and inspecting the Actor (to be precise, it’s particle system component) shows that both the relative and world location (in it’s transform tab) are set to apparently, correct values, however performing this switch world/relative within the Details panel while the game is paused starts teleporting the actor to the particle system, or particle system to the actor, or seperating them again to what they were when I paused the game, or any combination of these events (I guess, in regard to which component did I switch relative/world position view).
What is going on here, how can I have a particle system component simply following the needed Actor?
This specific actor has a USphereComponent set as RootComponent, and it does have a ProjectiveMovement component to it as well. Perhaps that’s influencing it’s physics somewhat?
I have temporarily solved the problem using this:
FPSTestProjectile.css:
void AFPSTestProjectile::Tick(float Delta)
{
Super::Tick(Delta);
Particles->SetWorldLocationAndRotation(RootComponent->GetComponentLocation(), RootComponent->GetComponentRotation());
}
The behavior in-game is as expected but this can’t be elegant solution I am looking for, can it? In addition, simply setting the world location and rotation doesn’t actually result in any velocity, which is a shame since the particle system also has it’s particles inherit the emitter’s velocity for additional effect.