vendredi 28 octobre 2022

How to change Time.deltaTime value?

Is there any way to change Unity's Time.deltaTime value with reflection or with some other method. We have a replay system which we use mainly for bug hunting. It stores all the input events and delta time values than we can simulate the game exactly the same . But to force delta time values we have to define and use a custom deltaTime variable. I want to get rid of that variable and also force unity's systems to use our value.

class SystemManager
{
     List<System> systems;
     void Update()
     {
          if(replay)
          {
               DTime.deltaTime = deltaTimeBuffer.GetValue();
          }else
          {
               DTime.deltaTime = Time.deltaTime;
          }

          foreach system in systems
               system.Update();

     }
}


class System
{
     void Update()
     {
          position += DTime.deltaTime * velocity;
          // I want to get rid of DTime.deltaTime and use Time.deltaTime
     }
}




Aucun commentaire:

Enregistrer un commentaire