Instanced Static Mesh doesn't rotate on instanciation

Hey guys ! I’m currently doing real time growing trees, and i’m using an instanced static mesh component for the foliage, since every leaf is unique. When I add an leaf instance to my component, I put a random rotation on it. But for some reason, this rotation is not set, all my leaves have a zerorotator. The scale is set, the transform too, but not the rotation.

Here is the code :

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

I recently changed the Instanced Static Mesh Component, I beggined to put it on a child actor, and the rotation worked. But I had to remove it for an other issue.

I’m sure it’s a small thing I’m missing, but I’m losing too much time searching on the internet, and there is not that much documentation on this subject…

Thanks :slight_smile:

What’s the relation between leafTrans and leafTrans2?

May be better do some test on your Transform. Like this:

for (auto i = 1; i < 100; i++)
{
	FTransform T;
	T.SetLocation({ i * 300.f, 0.f, 0.f});
	T.SetRotation(FQuat::MakeFromEuler({0.f, 0.f, 30.f * i }));
	foliage->AddInstance(T);
}

What does your tree look like now?

Oops, I made a mistake while copying my code. I add two leaf at once, so I instanciate two Transform, that’s why I got a “leafTrans2”.
Thanks for answering, I’ll try your test.

Ok, the problem was the scaling. For some reason, when it is set to zero, it also set the rotation to zero… Thanks for J0000J, I could put the finger on this issue. Thanks dude !