Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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

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 :)

Product Version: UE 4.15
more ▼

asked May 18 '17 at 09:41 AM in C++ Programming

avatar image

1 2 4

avatar image J0000J May 19 '17 at 05:33 AM

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

What does your tree look like now?

avatar image PoxPoxPox May 19 '17 at 08:38 AM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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 !

more ▼

answered May 19 '17 at 09:49 AM

avatar image

1 2 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question