Spawning Foliage

I have 6 static mesh shapes, I need to create and place a lot of them with various differences. So I am making a blueprint actor, where I can basically use exposed enums to select what variation I want and code whether the specific elements are visible or not.

That part works fine, but one element I need to turn off and on, is foliage - e.g. grass.

Firstly, I tried to place one of my shapes in the world and use the foliage tool to paint grass all over then I intended to merge it into a static mesh and place it in the BP to control it’s visibility. However, it crashed trying to merge thousands of static meshes.

I was hoping to somehow spawn the grass foliage onto the static mesh but the procedural foliage volumes don’t seem to be in blueprints.

Is there a method of spawning foliage/static meshes onto a static mesh inside a blueprint actor that I am overlooking?

Not quite sure I’m getting it here.

You place the blueprints using a script, or as actors with the foliage tool?

You can write your own foliage placement inside the BP, that’s something I’ve done. You get a lot more control of how and where the foliage is placed.

Ok, I see the confusion, I want to make 1 blueprint actor. I want to be able to place instances of it in different places around my map and control their transformations in a sequence to have them move around. But want to have different ‘conditions’ for each based on an enum.

Think of it like a car blueprint and I want to be able to turn things on and off or switch to different seats etc… only it isn’t a car, it’s more like a block of land that needs different foliage conditions that I can toggle through in the construction script.

If you could show me an example of how I would create my own foliage placement that would be amazing. Bear in mind that the shapes are all rectangles but the corners have been filleted (curved). I am going to have maybe 1000 instances of the bp, each I need to spawn thousands of foliage on so instancing is a must really.

Is this possible? Or am I going about the task all wrong?

I do see an instanced static mesh component I can add in the blueprint actor, but I have to add each instance separately. Is it possible maybe to make a volume or shape, set its size, trace down and on the first hit place an instance of my grass? Or better yet, place different instances with a plausibility of spawning to get some variation?

ISM yes, or HISM. If it was a grass clump, you only have as many actual meshes as your blueprint. Not too bad.

I think the problem, is that even if you could paint foliage all over them, when you move them, them foliage will not move with them.

Whereas if you use your own system, it will.

Also, if you REALLY care about only having only 1 grass mesh, you could instance it in the level BP or game instance, and pass a reference to that into your BPs.

There hedges are BPs with filleted edges and ISM ivy leaves

I turned on the ‘test hedge’ so you can see the spawn action

ivy

I think i found a solution in this video: UE 4 Minutes TUTORIAL Static Mesh Instance spawn along the grid - YouTube

However it spawns from the corner, do you know how I might adjust it to let it spawn from the center and let me input the x and y dimensions separately?

oh wait maybe your system is much better, it seems to take into account the mesh and just cover it with the amount you define - how is it made?

It’s been through quite a few iterations :slight_smile:

I started off with ‘random point in bounding box’. If you make a thin collision box and put it on one side, this works pretty well.

In the end, because of the ivy mesh, and random Z rotations, having them in a grid shape actually looked better :slight_smile: Although I’d recommend start of with random bounding box, especially if Z rotation doesn’t move the mesh much.

I’ll put the BPs in a ‘snippet’. Gimme 5…

and

Yes, that’s right. A grid. It’s a little more tricky to get the rotation right when you’re painting on the side of the mesh and the mesh is rotated :slight_smile:

See the above snippets.

One of them looks horrendous, but it’s not, it’s just a lot of repeating code…

Amazing, the bounding box style worked perfectly. You really are a hero! <3

1 Like

I have adjusted your code slightly in order to have it account for the filleted corners :smiley:

Posting here in case anyone else needs it too!

1 Like

Excellent :slight_smile:

However, really oddly, a clump of them spawn at the world origin point. Don’t imagine this will really cause any issues but can’t really see why it’s doing it either…

It must be something in the code, I guess.

You know there is a node ‘random point in bounding box’? :slight_smile:

( although that node doesn’t work if you tilt the mesh )

PS, you don’t need a trace, just the box, or X and Y.