Foliage in Blueprint

I basically want a moving platform (Blueprint) with grass/plants/foliage on it. The platform is very big, so i need a lot of grass…
The problem: I can’t paint foliage in the Blueprint. HISMs work, but i can’t place every piece of grass by hand…
Foliage tool seems to work in the Level-Viewport only.
"Convert selected Components to Blueprint Class" doesn’t work for foliage.

There must be a way to do this in unreal… my ideas so far:

  1. Convert the foliage to a static mesh (Bad, because i can’t edit the foliage after, good because it works)
  2. Place every grass mesh by hand (yey!)

Hello TankbusterGames,

You can achieve this effect in your blueprint by using an Instanced Static Mesh component, then in its details panel assign a static mesh. Then follow the steps below:

  1. Create a new custom function (I named mine Create_Foliage)
  2. Add a for loop and attach it to the beginning of your function set the first index to 0 and the last to any number you want (I set mine to 30)
  3. Get a reference to your instanced static mesh
  4. Pull off your instanced static mesh and get the Add Instance Node
  5. Split the transform pin on the Add Instance node
  6. Get the Random Float in Range node two times
  7. put in a min and max value (Match these to your platform, for mine I used -200 and 200)
  8. pull off from the Random Float in Range and get a Make Vector node
  9. Plug one random Random Float in Range into the X value in the Make Vector Node and the other into the Y Value
  10. Take the Return Value of the Make Vector and plug it into the Instance Transform Location pin
  11. Go to your event Graph and on event begin play run your custom function
  12. Set the Instance Transform Scale pin values to 1

Every time your Game begins your platform will have a static mesh in random locations if you want to do multiple static mesh types (EX. 3 different kinds of bushes) you will have to make an instanced static mesh for each and modify the custom funtion!

Good Luck Creating

Thank you , :slight_smile:
although random/square Placement isn’t what i wanted to archive, i could combine this with a heightmap for weight, add some more instances, and may get nice looking results…

So it seems there is atm no way to convert foliage into a blueprint asset…

Hi,

as I see this is answered, but I have a pun in here - Adding Instances via Blueprint might be very performance expensive! So I decided to share my code, which does exactly the same, but is circa 15% faster :slight_smile:

void ALevelTile::PlaceGrass(UHierarchicalInstancedStaticMeshComponent* Grass, int NumberOfInstances)
{
	FVector MinPoint(0, -2000, 0); 
	FVector MaxPoint(4000, 2000, 0);
	FBox Box(MinPoint, MaxPoint); //<----|| this might change in your case, I'm using 4000 x 4000 x 0 square || if you want to use different sizes/shape, I would recommend you to create some Getter fce to get size of your Box
	
	for (int i = 0; i < NumberOfInstances; i++)
	{
		FVector Location = FMath::RandPointInBox(Box); //<----------------|| here I'm creating random location
			float RandomRotation = FMath::RandRange(-180, 180); //<-|| here I'm creating random Pitch
		FRotator Rotation(0, RandomRotation, 0); //<--------------------------|| here I apply the random Pitch to create a random rotation
		
		Grass->AddInstance(FTransform(Rotation, Location, FVector(1))); //<-|| Here I do add this instance
	}
}