Announcement

Collapse
No announcement yet.

Changing the BaseID of a foliage instance?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    This move foliage to new component function would be great to have as an official blueprint node..

    Leave a comment:


  • replied
    Originally posted by DamirH View Post
    Well, after quite a bit of digging through the foliage system, I've found that AInstancedFoliageActor has a function called "MoveInstancesToNewComponent" which will take all the foliage attached to component A and attach it to component B. Thus, first I've created a small utility function in my BlueprintFunctionLibrary, like this:

    Code:
    void UMyunctionLibrary::UpdateFoliageBaseComponent(AInstancedFoliageActor* IFA, UPrimitiveComponent* OldComp, UPrimitiveComponent* NewComp)
    {
    IFA->MoveInstancesToNewComponent(OldComp, NewComp);
    }
    Hello Damir and thanks for this piece of code and explanations !

    As I tried to implement your solution in my game, I get some compiler errors... To call "MoveInstancesToNewComponent", I have to include InstancedFoliageActor.h ("Runtime/Foliage/Public/InstancedFoliageActor.h"), but my compiler is not happy and tells me that InstancedFoliageActor.generated.h cannot be opened :/
    Have you got this problem while working on this and if yes, how did you fix it ?

    Thanks a lot for reading

    Leave a comment:


  • replied
    No problem! I'm sure I'm not the only one who needed this. =D

    Leave a comment:


  • replied
    Nice, thx for posting!

    Leave a comment:


  • replied
    Well, after quite a bit of digging through the foliage system, I've found that AInstancedFoliageActor has a function called "MoveInstancesToNewComponent" which will take all the foliage attached to component A and attach it to component B. Thus, first I've created a small utility function in my BlueprintFunctionLibrary, like this:

    Code:
    void UMyunctionLibrary::UpdateFoliageBaseComponent(AInstancedFoliageActor* IFA, UPrimitiveComponent* OldComp, UPrimitiveComponent* NewComp)
    {
    	IFA->MoveInstancesToNewComponent(OldComp, NewComp);
    }
    After that I've gone ahead and made a Blueprint that would take care of the heavy lifting (Possible to do it with Blutilities too). This is where it got tricky. First I had to figure out which component on the landscape foliage attaches to. After quite a bit more digging it turned out to be something called Landscape Heightfield Collision Component. Each of your landscape components has one of these. Having that only one thing remained - since my two landscapes don't have the same number of components, I had to figure out which component to map to which. I made a small "find closest component to this component" algorithm to do that mapping and it called the above utility function on them. Here are images of the Blueprint:

    Click image for larger version

Name:	X2oS4l5.png
Views:	1
Size:	454.4 KB
ID:	1092362

    Click image for larger version

Name:	aXxk5mC.png
Views:	1
Size:	619.0 KB
ID:	1092363

    In the second screenshot, ClosestDistance default value is -1.

    (Sorry for the spaghetti, was trying to make everything fit in).

    The transfer foliage custom event is marked as "call in editor". Now just drop this actor into your level, select the two landscapes as his two variables and run the TransferFoliage event from the Blutility drop down.
    Last edited by DamirH; 10-31-2015, 08:20 PM.

    Leave a comment:


  • replied
    Originally posted by DamirH View Post
    I have actually found a very easy way to do this, but I haven't had time to make a writeup about it.
    Really? Would be cool if you could post it into this thread so that we know how it works

    Leave a comment:


  • replied
    I have actually found a very easy way to do this, but I haven't had time to make a writeup about it.

    Leave a comment:


  • replied
    Unfortunately that's not so easy. You could just copy it to your new level + then manually adjust the position of the meshes so that it fits to the terrain: https://answers.unrealengine.com/que...y-foliage.html

    Leave a comment:


  • started a topic Changing the BaseID of a foliage instance?

    Changing the BaseID of a foliage instance?

    Is this possible via a Blutility perhaps?

    I have need to transfer a ton of foliage from one terrain to another, so I need to figure out how to "attach" the instances to the new terrain object.
Working...
X