虚幻引擎:实例化静态网格物体不会在实例

时间:2017-05-18 09:52:50

标签: c++ unreal-engine4

我目前正在实时种植树木,而我正在为树叶使用实例静态网格物体组件,因为每片树叶都是独一无二的。当我向我的组件添加一个叶子实例时,我对它进行了随机旋转。但由于某种原因,这个旋转没有设置,我的所有叶子都有一个zerorotator。比例设置,变换也是,但不是旋转。

以下是代码:

//Instanced static mesh component instanciation, as a component of the tree
foliage = NewObject<UInstancedStaticMeshComponent>(this);
foliage->SetWorldLocation(GetActorLocation());
foliage->RegisterComponent();
foliage->SetStaticMesh(data->leaves[treeType]);
foliage->SetFlags(RF_Transactional);
this->AddInstanceComponent(foliage);

//Adding a instance of foliage
const FTransform leafTrans = FTransform(
FMath::VRandCone(normals[branches[i].segments[j].firstVertice + 2], 2.0f).Rotation(),
vertices[branches[i].segments[j].firstVertice + 2], FVector::ZeroVector);

foliage->AddInstance(leafTrans);

我最近更改了Instanced Static Mesh Component,我开始将它放在一个子actor上,并且旋转工作。但我不得不将其删除以解决其他问题。

我确信这是一件我想念的小事,但我在互联网上搜索的时间太少了,而且关于这个主题的文档并不多......

谢谢:)

1 个答案:

答案 0 :(得分:1)

好的,问题在于规模。出于某种原因,如果将其设置为零,它还将旋转设置为零...