Search Unity

Delta Time is zero on build PS4 but ok in PC

Discussion in 'Editor & General Support' started by eudendeew, Jun 8, 2019.

  1. eudendeew

    eudendeew

    Joined:
    Feb 5, 2017
    Posts:
    18
    I got this strange bug when building to PS4.

    I have this serialized class called SimpleTimer in which I can call a function that uses Time.deltaTime to move a variable, then return whether or not the time set timer is over.
    So in another Mono child, in Update I can do:
    Code (CSharp):
    1.  
    2. private SimpleTimer timer = new SimpleTimer(3f); // In seconds
    3. void Update()
    4.     {
    5.     if(timer.Check) // Property return true is time is over.
    6.         Debug.Log("time is over");
    7. }
    It works fine in the Editor, PC Build, Mac Build. But strangely, it doesn't work on PS4. Time.deltaTime is always zero from my SimpleTimer, so the timer cannot progress.

    What I've tried and didn't work:
    - Take out the [System.Serializable].
    - Initialize timer on Start instead of declaration.
    - Turn off/on VSync.
    - Added a Application.targetFrameRate = 60
    - Script execution order cannot be used since it doesn't
    inherit from MonoBehaviour
    - Making a PC-Host Build and PS4 Package Build

    What does work:
    - Doing what SimpleTimer does but in Update. Sadly at this point many scripts use SimpleTimer, I cannot copy paste it on all scripts.

    Could it be that my script tries to retrieve deltaTime before it is set by Unity?
    Does the Unity API run on a different thread in PS4?
    Haven't tried but maybe creating a static float let's say TimeManager.myDeltaTime that is set from Update() then retrieved in SimpleTimer could work?

    Unity version 2018.3.16f1
     
  2. eudendeew

    eudendeew

    Joined:
    Feb 5, 2017
    Posts:
    18
    * corrections (since it doesn't let me edit my post frequently)
    Unity version is 2018.2.16f1 not .3
    // Property returns true if time is over.