I found out about the non memory allocating version of Linecast and want to move to it, but I can’t for the life of me figure out how to get the syntax right to let it compile. The documentation simply says to at least have your start/end Vector 2’s, as usual, and then RaycastHit2D for the third argument. But this does not compile, it will say "Unexpected symbol “[”. The doc provides no actual script example, sadly =/
So has anyone used this version of Linecast yet and gotten it to work? Here’s an example of the code line I’m trying.
Physics2D.LinecastNonAlloc(groundCheckL_start.position, groundCheckL_end.position, RaycastHit2D[]);
I’ve tried it in a fresh/clean script as well, just to make sure it wasn’t an issue caused by something else in my script. And it’s definitely not the first 2 arguments, or at least shouldn’t be, as they are Vector2 positions which worked fine with the regular Linecast.
Reference: