I’m trying to create a 3d farming game on the unreal engine Is there a tutorial or path to learn how to make a system where the player can interact with the ground to create land to plant? There’s no way to interact with the landscape, right?
Here’s a tutorial on getting a location on the ground from cursor location:
With a similar approach, you can make your line trace detect objects by splitting it’s out hits pin and getting the hit actor. You can divide your map into grids and make your line trace only detect those individual squares rather than things on them by using a custom trace channel for them. And here’s a tutorial on custom trace channels:
You can then use nodes like Spawn Actor and Destroy Actor to add / remove things on your grids.
Hope these help!
I think it will help. I haven’t had time to test it yet. I forgot to mention but my game is in third person. But this idea of dividing into grids will make it easier to space out your creations.
I made these manual squares so I could plant, water and harvest, which works really well. But I wanted to give the player freedom to choose where they want to plant, you know.
You can also cast a line trace from the player to straight down and check if it hits one of your grids while using a custom trace channel for them
Ah yes, that’s what’s happening already. It has each land separated and highlights the selected land based on the mouse. But I wanted to make a limit on the player’s farm area like a grid system even though he always places it in a certain position
I’m not sure what you mean, could you please explain your objective more clearly? If you want to select multiple grids nearby by selecting only one, you can achieve that by using a 2D array. You can store the grids as object type variables and place them in a matrix to later calculate which will be affected by any given action.