Hey all! I have a dynamic material with some different layers. I have a grass layer, stone layer, and dirt layer. What I’m trying to do is let the player change what material is showing. In other words like in Minecraft when the player uses a hoe on the grass the grass disappears and is replaced by dirt. When the player clicks I want the to replace the grass with dirt. Thank you!
I don’t think you’re going to be able to do that without changing the engine code as I don’t believe the landscape is set up by default to be editable at runtime. Something you could do though is spawn a dirt mesh where you hoe the dirt to fake it.
Okay, so that means I’m going to need to change the way I’m spawning my grass? The grass is being spawned through my landscape material. Do you have any idea how I could dynamically place my grass so it would be instance editable? I’m trying to make it so my player can clear land so they can build on it. Thank you for the help!
Inside the Material editor there is a node for grass, which is used to mask in the landscape material for the places where it will receive grass or not. You will need a render target to be mapped to the extent of your landscape and this rendertarget will be the source to mask the places where you can place grass. In the Kite Demo (A Boy and His Kite) the landscape material is complex, but you can study it and you will see that node in action, which uses a splat mask in order to the material know where to put grass.
Hey! Thanks for your answer! Right now I am using the grass node in the material editor and I have it set up so the grass spawns on the material layer grass, but will not spawn on the layers stone or dirt path layers. What I’m trying to do is let the player, basically, “paint” the dirt path layer, so the grass will not spawn there. But apparently I’m not going to be able to do that, so I think I’m going to have to use a blueprint to spawn my grass. Do anyone have any idea how I will be able to let the player destroy the grass to clear the land? I’m thinking about letting them use ray-tracing but I’m not sure if that will take performance down. And suggestions would be great! Thank you!
In my previous post I have also answered to you, to let you understand better, there is this video which uses rendertarget to change the path the guy walks to deform snow, basically the difference is how you will change the rendertarget to use the resulting texture as a mask for the grass node!
Hmmmmm, I’m not sure that works with 4.20. I tried to make it and it didn’t work, then I downloaded the project files and they don’t work either.
Hmmm that project was made for 4.10 so it may not work, but you can download the 4.10 into your machine, run the project, watch the video and get the concept, because anyway it is not the solution for you yet, but it uses the principles you will need to mask the grass.