Hi, I’m making an RTS in UE4 and I’m trying to create nation territories that can change shape throughout the game (Like the District tool in City Skylines).
I’m thinking about using splines to do this, but am completely stumped.
Any help or tips towards solving this problem would be great.
You first have to create a point list from what you have. The points could be the actor positions, but that is not very precise. You can work with bounding boxes there too.
So you have your BorderManager or something object. There you have a function. It calculates inside points, and with the algorithm then calculates the vertices of the boundary polygon. You can save them. Everyone can query these e.g. for drawing.
You don’t need to calculate it every tick, only recalculte when the user places a new building.
I am able to implement this using UE::Geometry::TGeneralPolygon2, which is basically a vector of FVector2d that forms the perimeter of the polygon and its internal holes. The same module also provides useful functions for polygon union, difference, triangulation etc.
I then render the polygon district with a DynamicMesh.