Advice on creating a field (of crops)

Hi,

I’ve been researching creating a field in Unreal and I’d like to get some advice form more experienced people.

I’m trying to build a field, a large area of land, pretty much a grid. The player can change sections of the grid, so for example they could walk into the middle of the field, press E and have the area under them turn from grass to dirt.

I did some testing with instanced static meshes and that works pretty well, but is that the best approach?

I’ve been looking at dynamic materials, it looks like it’s possible to change a material based on a vector input, has anyone done this? And with some management the number of dynamic instances could be cut down as more change around a grid.

Is layered landscape an option? Is it possible to change the landscape material at runtime, a few posts say no, but just in case, I’ll ask.

If anyone has any advice, warnings or links, please shoot them this way as I keep digging.

Thanks,
Dave

I was looking at them, but I figured the mesh or material route would be better, since I’ll want to change things around the edges of the field.

Are there limits on decal usage? I’d imagine a field with 3k (random num) is going to be more work than instanced mesh or a dynamic material.

Decals are cheap, and middle ground between Material and StaticMeshes, have you gave them a shot ?

-m

Changing landscape layers at runtime is not supported, sorry (although it is a frequent request).

Thanks Gareth.

So what I’ve done is setup an actor with some instanced static mesh components. The field is created via the construction script using a simple row and col count.
There’s a border around the field, where dirt runs into grass.

I added a new blueprint that parents from hierarchical instanced static mesh component so that I could add some custom variables to it and use the cast as a check.
When you use or click on a tile, I raycast from the mouse, if the hit component is my new blueprint component then I know that it’s a tile I want to swap. Then it’s just a case of adding an instance from one and removing from another, allowing me to swap between dirt and grass as needed.

This works fine, performance is fine even on massive fields (16k tiles for a big test).

When running bigger fields, I get the warning in the logs:
LogPhysics:Warning: PHYSX: (…\LowLevel\software\src\PxsAABBManager.cpp 540) eINTERNAL_ERROR : A PxAggregate has exceeded the limit of 128 PxShapes. Not all shapes of the aggregate will be added to the broapdhase
LogPhysics:Warning: PHYSX: (…\SimulationController\src\framework\ScElement.cpp 107) eINTERNAL_ERROR : Unable to create broadphase entity because only 32768 shapes are supported

Everything runs fine, no collision is lost, I’ve swapped all tiles in a large field and I can still stand on them without issue.
From looking at this error, others have had it.
How is this approach to building the field? Should I be going at this another way?

Thanks,
Dave

Any advice / answer to the rest of the question?

To avoid the occasional error from happening, instead of removing and adding tiles, I just move them via UpdateInstanceTransform.

This solves the problem, and doesn’t have much overhead.

For anyone that comes across this thread in the future. It was easier to go with the swapping method.
The construction script sets up the tiles in an instanced static mesh component, as each tile is being created a custom component is also added, this holds the ‘crop’ location and some info about the tile under it (instance index).

When the player is over it, the interact and it picks the closes ‘crop’, this switches the tiles and you get the effect you (I) need.
Performance is fine, and there are no issues with the collision.

My next steps are to play with some spline placement to create slops and to swap out individual tile collision for plane collision.

I’m going to mark this as the answer, if anyone from Epic would like to jump in and say “no, do it this way!”, please do.

Cheers,
Dave