So I want to make a farming game, similar to farming simulator. However I’m not sure how to go about the farm lands themselves. Ive done a bit of research and PCGs was the first thing I saw that might work for what I want to accomplish but I’m not positive it will, or if its the best approach.
Essentially what I wish to accomplish is the ability to have pre-defined farm fields the player can interact with using equipment i.e. seeding, cultivating, harvesting etc. But also want the player to have the ability to expand the field via plowing or even create entirely new fields where none existed previously.
All the info ive found on “farming” in UE has been more like gardening…planting individual plants in a planter ARK style.
I wish it were something simple like shooting a line trace to detect the landscape, and spawning a field mesh that meets the appropriate field state.
Anyone have any clues that could point me in the right direction?
So in my initial look into this everything I found said there was no way to change the landscape at runtime, which Is why I figured PCGs was the way.
However looking further into the subject it seems it is infact possible to change the landscape texture at runtime with a dynamic material instance. Thankfully ill have the next 6 days off from work and can test this out. If that works and I can dynamically “paint” fields by destroying grass foliage actors and updating a grass texture to a plowed field texture, as well as updating textures for other field states via line traces from the equipment used.
I guess the next step after that would be figuring out how to access a reference to the field to apply game play logic to it. Like assigning state tags and spawning crops etc.
Hey there @BoostedCR24! As you’d already found out, the landscape system isn’t meant to be changed much at runtime. Material changes are generally fine, but when it comes to trying to manipulate the terrain itself, I’d usually recommend Voxels for high terrain modification, or rolling your own deformation with procedural meshing.
As for crops, most users tend to use Instanced Static Mesh(ISM) or Hierarchical Instanced Static Meshes (HISM) for crops or interactable (like resource nodes) trees, rocks, etc. This makes it easier to render tons of them, and you can handle them via one location. However It does make it a bit harder to do special mechanics with them due to their limited nature.
@SupportiveEntity I had heard voxel landscapes were fully interactable. And now that I think of it farming simulator uses a voxel landscape themselves if im not mistaken since they have terrain deformation and real-time landscape sculpting, albeit they are using their own game engine.
If its voxelized as opposed to the normal terrain do you think that would allow me to have the functionality of detecting fields and applying states e.g harvested or cultivated, set growth cycles and what not.
I think thats the thing most melting my brain at the moment…is, even if coded all the functionality how would I go about actually applying it to the landscape.
This is going to depend entirely on how you’d expect those mechanics to play out. For example, a “field” could just mean crops of the same type in an area for some games, but in others you may want an actual structure to them. This could be user defined by just some bounds, or tied to an actor that acts as the manager for the field itself, or a myriad of other possibilities depending on the use case. Do you have a design you’d like to pull off for this mechanic? It’s hard to get into specifics when there’s tons of possible options depending on your plans with it.
So the way I’d want it to work would be: You have a field, the field would visually represented by various textures on the landscape that show the state of the field. The player would interact with the field using tractors and other equipment to prepare, plant and harvest the field.
Id want to be able to plug in functionality for the “states” of the field that would determine the next step the player needs to make. But also variables that can increase or decrease the harvest yield such as fertilizer, or weeds, weather, soil composition.
As for the crops themselves, they would be spawned on the field in various growth states until they reach maturity and then can be harvested.
In the grand scheme of things there would be many fields on the map the player could purchase and work, so probably a global field manager class that just logs the states and variables of the fields and informs the player.
If it’s just textures and the landscape, you could get away with using the landscape system or just a dynamic mesh and Runtime PCG instead of voxels. I generally use voxels for being able to “dig” into terrain or build it up in shapes that 2D landscape data couldn’t do.
It sounds like those fields could honestly just be bounds set up to determine where the PCG elements are supposed to generate, and doing any of the actions (Tractor, Harvester, Planter, etc) in that area would just paint (using render textures possibly) the textures to the landscape, call for PCG generation of elements there, then handle the field itself and it’s characteristics as data.
I’ve been looking into voxel plug-in 2.0 (hasn’t fully released yet) but looks pretty impressive what one could accomplish with it. Might be useful for other aspects even if not needed persay for the farm fields.
I read the thread you linked, it mentioned you couldn’t use nanite on the landscape using that method, which I’m not sure if it’d be a deal breaker or not. Could give it a try.
My other thought was possibly spawning a thin mesh over top of the landscape that would represent the field and use displacement. But i think thats what you were getting at when you said “dynamic mesh”
Then I believe its RVTs? That can blend the mesh in with the landscape so it all looks as one.
Voxel plugin is powerful for sure. I’ve used it for a couple projects and enjoyed it. If your game’s aesthetic will allow and you can make use of runtime terrain capabilities.
Nanite landscapes are nice if you have higher definition landscapes or very large ones, but you miss out on runtime editing that voxels provide.
Dynamic mesh is really just modifying a mesh whenever you need. Displacement is just changing where the vertexes are rendered instead of modifying the mesh.
RVTs on preestablished meshes are also good if you want nice blending, and you can drag them wherever and they should blend seamlessly on any terrain textures.
I was aiming at having a more realistic overall look. With all the machinery being based on real life equipment.
I was looking at voxel plugin’s smooth voxel terrain which if i recall supports nanite for high quality terrain. Which would be great, i may not need it for the fields but it dawned on me that I may want to implement player placeable buildings such as grain bins and what not and that real time terrain deformation to match the building’s foot print would come in handy, along with the ability to allow the player to modify the terrain to their construction needs.
That would atleast solve the real time terrain aspect. As for the fields they’d probably still just be a dynamic mesh overlayed on top of the landscape that’d leverage nanite displacement for the cuts and grooves made by the farm equipment.
One of the great things about Voxel plugin is how extensible it is, you could go the route of having it be it’s own mesh or just a voxel modification overlaid on top of the terrain voxel itself. The dynamic mesh portion is still fine, but you’ll have to try and and match how the smooth voxelized terrain looks, which could be fine (as you could also use marching cubes like they would) or it could be more effort.
If you want the players to manually cut the grooves with tools/vehicles, that is probably the coolest way to do it, but you’ll have to manage your constraints well. It’s a step beyond Farming Simulator’s mechanics and could make your game stand out, but it could also be finicky if you don’t manage it well.
You’re absolutely right, the player making the cuts would indeed be a lot cooler than just a mesh or texture. The thought had definitely crossed my mind but I wasn’t sure if that was possible. Ive only seen what they’ve posted on youtube and the deepdive video unreal posted but I may have to just make the purchase and start playing with it and jump on their discord.
Feel free to play with the free version they have available. It doesn’t have all the features, but it should give you a basic idea of how it works and how you’d work with it.