I need to know how to spawn a Particle System Component like this in C++.
@see UK2Node_AddComponent DO NOT CALL MANUALLY - BLUEPRINT INTERNAL USE ONLY (for Add Component nodes)
What is the C++ equivalent?
I finally get it!! this is the answer : First on the .h file :
Define this two
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "ThrowPosition")
UParticleSystemComponent* BeamComp;
TArray<UParticleSystemComponent*>BeamArray;
Next on the .cpp : this goes on the constructor :
// beamcomponent
BeamComp = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("BeamComp"));
BeamComp->SetupAttachment(SpringArmComp);
BeamComp->bAutoActivate = false;
And this is the function –
void ASCharacter::AddNewBeam(FVector Point1, FVector Point2)
{
BeamComp = UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), BeamFX, Point1, FRotator::ZeroRotator, true);
BeamArray.Add(BeamComp);
BeamComp->SetBeamSourcePoint(0, Point1, 0);
BeamComp->SetBeamTargetPoint(0, Point2, 0);
}
– Hope this helps you.
1 Like
Thank you!!!
you are very welcome mate!