Time.timeScale不适用于Unity.Physics软件包(DOTS)

时间:2020-02-15 09:21:50

标签: unity3d entity-component-system unity-dots

如果我设置Time.timeScale = 0;如果设置Time.fixedDeltaTime = 0,则没有任何变化。我的物理对象开始表现异常,但并没有完全停止。 也许有人知道如何更改DOTS物理的timeScale

1 个答案:

答案 0 :(得分:0)

Unity.Physics\ECS\Base\Systems\StepPhysicsWorld.cs 函数内的 OnUpdate() 中,使用您的标量修改 timeStep 值,使其看起来像这样:

float timeStep = Time.DeltaTime * PhysicsSettings.TimeScale;

// Schedule the simulation jobs
Simulation.ScheduleStepJobs(new SimulationStepInput()
{
   World = m_BuildPhysicsWorldSystem.PhysicsWorld,
   TimeStep = timeStep,
   Gravity = stepComponent.Gravity,
   SynchronizeCollisionWorld = stepComponent.SynchronizeCollisionWorld > 0,
   NumSolverIterations = stepComponent.SolverIterationCount,
   SolverStabilizationHeuristicSettings = stepComponent.SolverStabilizationHeuristicSettings

}, m_Callbacks, handle, stepComponent.MultiThreaded > 0);

其中 PhysicsSettings 是我用于存储点物理全局变量的类。