CreateDefaultSubObject sets as RootComponent

Hi.

Want to add some ParticleComponent as suboject in ATank - after tank death and became non-active - let it be in smoke and fire.

class ATank {
...
	UPROPERTY(VisibleAnywhere, Category = Components)
	UParticleSystemComponent* RuinsParticles = nullptr;
...
}

ATank::ATank() {
...
	RuinsParticles = CreateDefaultSubobject<UParticleSystemComponent>(FName("Ruins Smoke"));
	RuinsParticles->AttachToComponent(GetRootComponent(), FAttachmentTransformRules::KeepRelativeTransform);
	RuinsParticles->bAutoActivate = false;
...
}

And that component sets as root. But some component (like tracks) expect root component is a mesh to work with.
How to add component not as root? Or add it not in ctor? Or add BaseTankMeshComponent with tank body mesh and set particle to this component and change the tank bp accordingly?
Which way is right?

1 Like

Privacy & Terms