虚幻引擎:实例化静态网格体在实例化时不旋转

Unreal Engine : Instanced Static Mesh doesn't rotate on instanciation

本文关键字:实例化 旋转 静态 引擎 网格      更新时间:2023-10-16

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

这是代码:

//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);

最近更改了实例化静态网格体组件,我恳求将其放在一个儿童演员身上,旋转起作用了。但是我不得不为其他问题删除它。

我确定这是我错过的一件小事,但我浪费了太多时间在互联网上搜索,而且关于这个主题的文档并不多......

谢谢:)

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