在Actor中包含了很多的网格体或者粒子组件,如何获取它们?可以通过一下函数函数
文章来源:https://www.toymoban.com/news/detail-623552.html
//爆炸后的烟雾效果
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FlyingPawn")
UParticleSystemComponent* smokeParticle;
//碰撞时发生的粒子特效组件
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FlyingPawn")
UParticleSystemComponent* explodePartcileComponent;
//获取所有的粒子系统,烟雾粒子和爆炸粒子系统
TArray<UParticleSystemComponent*> Jets;
GetComponents(Jets, true); // true表示获取子Actor的组件
for (int32 i = 0; i < Jets.Num(); i++) {
FString name = Jets[i]->GetName();
if (name == TEXT("SmokeParticleSystem")) {
smokeParticle = Jets[i];
//关闭特效
smokeParticle->Activate(false);
smokeParticle->bAutoActivate = false;
smokeParticle->SetVisibility(false);
} else if (name == TEXT("ExplodePartcileSystem")) {
explodePartcileComponent = Jets[i];
explodePartcileComponent->Activate(false);
explodePartcileComponent->bAutoActivate = false;
}
}
aaa文章来源地址https://www.toymoban.com/news/detail-623552.html
到了这里,关于UE4获取Actor下面的组件的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!