Physics optimization and Physics.Simulate()
I have a performance issue, and I'm hoping someone can help in regards to optimization. I'm making a golf game, and I have a predictive path that is drawn by simulating physics on each frame.
In order to do this, I'm calling Physics.Simulate() about 200 times a frame. The physics simulation takes up about 100ms per frame.
I've been looking into Unity's ECS and Job system, but I'm still in the learning process of this method of writing code. Is there a way to apply these simulations in a more efficient way, or am I stuck with a high-cost physics overhead? Any help or ideas would be greatly appreciated.
Answer by tedesignz1 · Apr 21, 2018 at 10:16 AM
I'm gonna go ahead and answer my own question. Turns out trying to multithread a physics simulation is kinda silly to begin with. Needless to say, Physics.Simulate can only run in the main thread. This should have been obvious to me at the start, but there you go.
I was able to get the most out of the engine by removing rigidbodies from scene objects and increasing the physics timestep.
Your answer