Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice

What is "Physics.SyncRigidbodyTransform" and how do I get rid of it?

Discussion in '2017.2 Beta' started by Peter77, Aug 9, 2017.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,171
    I just profiled my project in 2017.2.0b6 and noticed a lot of these calls:
    • Physics.SyncRigidbodyTransform
    • TransformChangedDispatch
    • WaitForJobGroup
    It seems every time any physics related state is queried, such as a Physics.Raycast, Unity is doing in 2017.2 something it didn't do before? I can't remember to have seen all those Physics.SyncRigidbodyTransform calls in earlier builds, such as 2017.1 for example.

    What is that and how do I get rid of it?
    physics_syncrigidbodytransform.png
     
  2. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,780
    It actually did those syncs before, but it was done in background; not exposed to users. Now you have the option to manually sync rigidbody position with transforms if you're interested in maximizing your performance. I'm guessing it only shows up in the profiler now because it's something users can have access to, and because they made a new API for it

    See:
    https://docs.unity3d.com/2017.2/Documentation/ScriptReference/Physics-autoSyncTransforms.html
    https://docs.unity3d.com/2017.2/Documentation/ScriptReference/Physics.SyncTransforms.html

    Basically, Unity by default will always try to check if you have rigidbodies that need syncing whenever it does any sort of physics query. This is a "safe" approach for most users who aren't too tech-savvy. But if you know your stuff, depending on your game, you can get away with waaaaaaaaaaay less sync calls if you take care of it manually. Maybe even just one sync per fixedUpdate could be enough in a situation where you'd have a hundred sync calls per frame by using autoSync

    From what I understand (and I'm not sure if I understand correctly yet), the Sync calls are only useful for when you moved a Transform that has an attached Rigidbody/Collider. In theory, this isn't something that will happen very often at all, because the better thing to do would be to move the Rigidbody directly. So I think only one sync per frame is necessary in most cases if you do things properly and never move collidable stuff with Transform directly. But I really need to do some tests on this and/or ask the devs about this

    Edit: started a thread here: https://forum.unity3d.com/threads/physics-synctransforms-questions.487424/
     
    Last edited: Aug 9, 2017
unityunity