Search Unity

Using RaycastCommand is just too rigid

Discussion in 'Entity Component System' started by JakHussain, Sep 8, 2019.

  1. JakHussain

    JakHussain

    Joined:
    Oct 20, 2016
    Posts:
    318
    From a design perspective, RaycastCommand bring about a lot of inconveniences. Half of the time, sure, I want to cast each and every ray and process the results of each of them. The other half of my usecases with raycasting is to check each ray UNTIL one does or does not hit something, execute some logic, then exit my loop. With the way RaycastCommands work, this workflow is impossible. What are my options here? Sometimes its genuinely slower to cast every ray and check all the results (even in parallel) than to just cast the first few until I find the result I'm looking for.

    The code gets so ugly and difficult to read when physics querying gets involved with any jobified code. I want maximum performance and this API honestly make me lose performance at times.

    Has anyone come across the same issue as me and if so, how did you work around it?
     
    thelebaron likes this.
  2. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
  3. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Ya it's problematic when you want to do raycasting in sequence with other logic. This is was my primary motivator for moving to Unity.Physics. Even if you have duplicates, Physx and Unity.Physics colliders, it can still be a win. We have a lot of duplicates because while Unity.Physics is great for a lot of query related stuff, we have way too much feature logic using Physx to replace it all with Unity.Physics.