Creating dynamically updating AI field of view for RTS

G’day,

So I’ve been struggling to find a way to articulate the geometry function/formulas required to solve this problem to the point that I’m questioning if my approach is the most optimised approach anymore.

In essence I’m trying to re-create this effect, which is from Broken Arrow, an RTS that recently launched a play test.

In essence it’s the user holding a keybind down and moving a mouse and then it creates a visual in radius of the mouse which needs to be dynamic (either a base value or a AI unit’s range).

The problem I’m running into relates to the actual generation of the visual, I’ve scoured a few posts, articles, etc and only really came across one that seemed to have somewhat of a similar design, however his method of achieving the effect didn’t seem all that performance reliable and was wondering if I got any advice on the approach to achieve this effect.


(Their result)

Currently my approach is currently calling a GetPartBoundsInRadius function with a whitelist filter of fugazi collision parts that encapsulate building or other objects. Then essentially getting the corner point of all parts within that radius and getting the bottom corners on the face with the closest magnitude to the origin position (mouse position), and then generate triangles using the origin, corner1, corner2 positions. Beyond that I’m not sure if I’ve missed a post or update about the ability to make complex meshes/geometry via scripts or such so I’m a bit stumped on how scalable my approach is.

Solution Considerations:

  • Visual will essentially have to run the entire method every frame (is purely local, so I’m worried about casting a raycast every 360 degrees, every frame)
  • Certain objects will have to modifiers that change the visualisation (units being in forests, with trees, etc)
  • Visualisation will have to take into account the height of the unit, with higher altitudes being able to see over obstacles and lower altitudes restriction vision.
  • Possible requirement of terrain integration (more than willing to utilise fugazi collision parts in the event of engine limitations)

Thanks for any assistance,
xg

1 Like

Not sure if this would work, however, just sitting here thinking about it, what if you only fire rays across the area of an obstacle, starting with closest obstacle, and block out any that end up behind the ones you cast. Its hard to explain what I’m thinking, but basically use a sorted list of objects that could potentially block sight in order of closest to farthest, and sort of eliminate candidates.

Yeah right, I actually sent you a DM on discord regarding this a few weeks ago trying to scratch ya head for it.

I’m less so looking for the method to get the area and more so generating the visual for the area, which you showed in your post that I referenced here.