Search Unity

Feedback rename RaycastNonAlloc RaycastAllNonAlloc

Discussion in 'Physics' started by laurentlavigne, Jun 5, 2020.

  1. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,327
    It's confusing, the nonalloc is NOT Raycast, it pierces through colliders like RaycastAll
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,455
    There's no behaviour difference. It's all about how many results are returned only.

    TBH I don't see that being confusing at all. NonAlloc can return a single result or all (depending on the size of the array provided) and the API docs describe the arguments and what it does anyway. That said, I'm not in charge of the 3D physics API so this is only my opinion. :)

    For 2D, all the non-allocs are tentatively deprecated too and all calls are made through the single overloaded Raycast (same with every single 2D query) allowing a single result or results in an array or generic list so no GC issues if used correctly. The "All" is convenient but horrible in that it returns a new array each time it's called.
     
    Last edited: Jun 6, 2020
    laurentlavigne likes this.