Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Huge slowdown after RaycastCommand ( Physics.SyncBatchQueries )

Discussion in 'Entity Component System' started by TheJavierD, Jun 19, 2020.

  1. TheJavierD

    TheJavierD

    Joined:
    Jan 6, 2017
    Posts:
    50
    Hello, I'm hoping someone can help me understand what is going on in my App.

    I'm making a huge number of Raycasts with RaycastCommand, it's all working but the problem is that my game still freezes because for some reason Physics.SyncBatchQueries halts the main thread execution until they are done.

    The freeze occurs when one of my rigidbodies tries to move (unrelated to the raycasts)



    And this is another view, I am not sure why one of the raycast commands seems to be executing on the main thread, maybe I'm just reading that wrong.



    Could anyone please help shed light?. Version is 2019.3.10f1
    Thanks!
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
  3. TheJavierD

    TheJavierD

    Joined:
    Jan 6, 2017
    Posts:
    50
    I thought so too and tried that, but it still does the WaitForJobGroupID and freezes the app.

    I'm assuming that this wait is intentional, if a rigidbody moves when there's pending raycasts to do it all waits until they finish to guarantee that they execute in the same physics state when they were requested.

    In my case, that wouldn't really matter but I understand if this is why there's a wait. The documentation doesn't say really what happens in this case so I was confused.

    I'm in the process of splitting up the raycasts in batches so this stops happening, so it shouldn't be a problem but It'd be nice to know what's really going on.