[SOLVED] At the beginning of unity physics simulate has low performance

Hello! I use DOTS unity physics in my new project.

There are 140 Entity collide at the same time, but at the beginning of unity physics simulate has low performance. like this snapshot :

when the physics runs a while:

this is my code on creating objects :

void AddEntity(GameObject LevelReference)
    EntityManager manager = MainSystem.Instance.EntityManager;
    Entity Reference = MainSystem.Instance.SystemData.PoolGameObjects.E_Object;

    NativeArray<Entity> E_Objects= new NativeArray<Entity>(LevelReference.transform.childCount, Allocator.TempJob);
    BlobAssetReference<Collider> sourceCollider = manager.GetComponentData<PhysicsCollider>(Reference).Value;
    manager.Instantiate(Reference, E_Objects);

    for (int i = 0; i < E_Objects.Length; i++)
    manager.SetComponentData(E_Objects[i], new PhysicsCollider { Value = sourceCollider });
    manager.SetComponentData(E_Objects[i], new Translation { Value = LevelReference.transform.GetChild(i).transform.position });


I wonder how to optimize this situation, Like deal these job(Process Body Pair Job, Build Contact Jacobians Job)in advance, or reduce processing time on these job.

thanks! :)


I do some testing :

  • When created entity , pause and wait for a while will let FPS drops to normal immediately.


Thanks for tertle's answer ! :)

If check this option, I have to compiled to continue the game, but in that way, application will stop for a while, I don't want that in the final version.

So I try to build game and test performance -- burst are building in very few milliseconds! every thing is fine now ;)

But when I test game, it still have times to compile burst. If you know how to solve this problem, please tell me, thank you!

Do you have asynchronous burst compiling on? The burst jobs probably haven't compiled yet. What does it look like if you enable synchronous (or in a build.)

!!!!!!!!:hushed: you are right :hushed: !!!!!!
But before burst jobs compiled, Unity will become unresponsive.
Can I compiled in advance?