Circular line trace

Is there a way to do a line trace, but in all directions along a single plane. Imagine a hoolahoop around your waist and then expanding outwards until you tell it to stop and returning each of the objects it hit in an array.

The reason I need to do this is because i’ve got a grid of tiles and I need each tile to be able to detect the other tiles around it. They aren’t laid out in a grid like pattern so I can’t predetermine the position beside or anything. I figure tracing from one object in all directions would be the best way to go.

Do I have to do a loop and lerp the rotation until I get all the way around and then manage whats collected from all of those? Or is there a single thing I can do?

As long as you aren’t concerned about the height, you can use either MultisphereTracebyChannel or MultiSphereTraceForObjects. They’ll both return an array of items within a pre-set radius.

Hello ryandlf,

there is a special set of traces which use primitive shapes. An example use can be found here. Alternatively, you can also add a collision component to your child and call GetOverlappingActors on it; collision components can be resized at runtime. I recommend a cylinder as you suggest a hollahoop.

As traces are somewhat costly, you may also consider encoding some information with your data. For instance, if it helps, in the Minecraft API (non-unreal of course) there is a function for obtaining a block at a vector; internally it uses data structure which achieves the equivalent querying a 3-dimensional array. Another example, in one of my own projects I had square tiles which were aligned like in a chess game; each tile had a neighbour to the north, east, south and west. So, I gave every tile four neighbour tile pointers and set those when I initialised the tiles. Note that this essentially makes your tiles vertices in a graph allowing you to use the vast amount of well-researched graph algorithms out there.