I need some help determining if the ground is flat enough for a building to be placed on (RTS style). I would appreciate any help.
Hi ,
You can run a series of traces down from the building you are placing. (I would recommend 4 to 5 points, 1 for each corner and perhaps one in the middle for most standard buildings). If each point == the same vector you can place, if not you cannot.
In the community rts template project which I use for my project it uses a trace, taking the hitresult and checking the “Impact Normal” how the slope is.
It only checks for the exact point where it is placed and since I’m using a grid placement this works perfectly well but you might want to do this for all corners as commented.
Anyway to give you an idea of how it looks like, here is my current slope check setup:
Here we have the trace and the Hit result which go into a collapsed part (this is just a part of the code put into a kind of function which still is in the same graph technically but not visually anymore. If you have a lot of nodes it starts getting slower and taking quite a lot of time for each node placement and line you draw so it comes in quite handy).
From inside of this collapsed node the results go directly inside of the “Is Valid Build Location” function.
And here inside of this function is the actual check of how large the slope is.
It works quite well for my purpose.
Thanks for the answer, this works reasonably well.