I initially did do Raycast. Hasn’t been working for me though, so wanted to try this to see if it would solve my problem. Still working out the kinks with Linecast, but it looks like it’s working better for me than Raycast was. My first issue (still current) is here.
The thing about the regular Raycast methods in both 3D and 2D is that they generate garbage with each usage because an class object to store the hit info has to be generated each time. With NonAlloc you provide a pre-defined container for the info to be output to instead, reducing workload and creating zero garbage.
Raycast creates a single struct, the RaycastHit info, no garbage.
RaycastAll allocates memory, because the array of RaycastHit, and arrays are a class type.
RaycastNonAlloc is like RaycastAll, without the array allocation, since you create it yourself and can recycle it.
And the 3D version of Raycast actually returns a bool, you explicitly pass in a struct ref for the RaycastHit to be assigned to. Which isn’t necessary, so you can just test if a hit occurred, and not get the hit info.