Unity Community

Register or Sign In:

+ Reply to Thread
Results 1 to 10 of 10

  1. Location
    Bronx, NY, USA
    Posts
    187

    Time.smoothDeltaTime ???

    (This was asked in the WishList Topic, but I feel my reply would be more helpful, and more properly put, here.)

    Quote Originally Posted by frenchie16
    4) Time.smoothDeltaTime
    I don't even know quite what this is for. The documentation just says it is a smoothed Time.deltaTime. It doesn't explain how much it is smoothed, what effect using it will have, or any other information.
    Code:  
    1.  smoothDeltaTime = (current delta time + (sum of 'n' previous delta times)) / ('n' + 1)
    Using smoothDeltaTime limits the effect of sudden fluctuations in deltaTime.

    Example:
    Code:  
    1.    deltaTime          smoothDeltaTime ('n' = 2)
    2.     --------           -------------------------
    3.     ...               ...
    4.     0.25               0.25
    5.     0.25               0.25
    6.     0.25               0.25
    7.     0.95 (+380%)       0.4833 (+193%)
    8.     0.25 (-73%)        0.4833
    9.     0.25               0.4833
    10.     0.25               0.25   (-51%)
    11.     0.25               0.25
    12.     ...                ...

    In the table above, you see deltaTime is going along steadly at 0.25, but then suddenly it spikes up 380% to 0.95 then drop down 73% to 0.25. The visual effect of the spike would be everything suddenly moving 380% more units than the previous frame.

    The smoothDeltaTime, since the values are averaged over several frames, only sees a jump of 193%. And when it does drop back down to normal, the drop is only 51%. Now, while there will still probably be a visually noticible "hitch", it won't be as drastic as the deltaTime hitch. The hitch will have been spread, or "smoothed", out over several frames.

    I agree, it would be nice if some of the descriptions where expanded on, but hopefully my little description will help in the mean time (and is not too far off the actual mark)
    David


  2. Posts
    2
    Quote Originally Posted by DGuy View Post
    (This was asked in the WishList Topic, but I feel my reply would be more helpful, and more properly put, here.)



    Code:  
    1.  smoothDeltaTime = (current delta time + (sum of 'n' previous delta times)) / ('n' + 1)
    Using smoothDeltaTime limits the effect of sudden fluctuations in deltaTime.

    Example:
    Code:  
    1.    deltaTime          smoothDeltaTime ('n' = 2)
    2.     --------           -------------------------
    3.     ...               ...
    4.     0.25               0.25
    5.     0.25               0.25
    6.     0.25               0.25
    7.     0.95 (+380%)       0.4833 (+193%)
    8.     0.25 (-73%)        0.4833
    9.     0.25               0.4833
    10.     0.25               0.25   (-51%)
    11.     0.25               0.25
    12.     ...                ...

    In the table above, you see deltaTime is going along steadly at 0.25, but then suddenly it spikes up 380% to 0.95 then drop down 73% to 0.25. The visual effect of the spike would be everything suddenly moving 380% more units than the previous frame.

    The smoothDeltaTime, since the values are averaged over several frames, only sees a jump of 193%. And when it does drop back down to normal, the drop is only 51%. Now, while there will still probably be a visually noticible "hitch", it won't be as drastic as the deltaTime hitch. The hitch will have been spread, or "smoothed", out over several frames.

    I agree, it would be nice if some of the descriptions where expanded on, but hopefully my little description will help in the mean time (and is not too far off the actual mark)
    Thank you for sharing.
    The documentation hasn't been updated yet :-/


  3. Location
    Texas, US
    Posts
    174
    I didn't even know there was such a thing as smoothDeltaTime. Thanks for explaining this. I'm sure I will use this at some point.


  4. Location
    Paris
    Posts
    2,884
    Just for information if any docs manager comes by this section :
    April 2012 (4 years later), and the docs about it are still vague. I had to Google search "smoothDeltaTime" to find out further explanations here.
    Last edited by n0mad; 04-09-2012 at 03:11 AM.
    Kinetic Damage, a 3 years long fighting game project :
    Official Site : www.kineticdamage.com
    Facebook page (blog, articles, dev updates).
    Dev Blog : Giant thread (+ additional tips & techniques)
    -----
    Tip Forwarding : Unity Video tutorials


  5. Posts
    554
    The doc is quite hurting in some parts. I wonder why they didn't make a wiki version where anyone could contribute to keep things updated.
    DRM is a sin. Say NO to DRM. Keep clean.


  6. Location
    Germany
    Posts
    855
    Quote Originally Posted by Morning View Post
    The doc is quite hurting in some parts. I wonder why they didn't make a wiki version where anyone could contribute to keep things updated.
    Cause the docs also have to be accessible offline and it doesn't work with Wikis? :P
    C# Developer
    www.Atomic-Gear.net
    Games:
    The Pirate Game: Android Market Link


  7. Posts
    554
    Quote Originally Posted by Tseng View Post
    Cause the docs also have to be accessible offline and it doesn't work with Wikis? :P
    You can have manual for offline use + an online version and a separate wiki just for online where users can add things. Many applications use this sort of method and it works wonderfully.
    DRM is a sin. Say NO to DRM. Keep clean.


  8. Location
    Rome
    Posts
    628
    Thanks DGuy for the useful information, and thanks n0mad for bumping this

    Unity docs should really be taken more seriously by the Unity guys. The amount of time that a Unity user has to lose to get information about things that should be well documented is absurd. Online searches, forum help, direct trial and error testing. And all this not to find solutions to issues, but just to understand undocumented (or badly documented) API. If we count these hours as working hours, Unity costs a LOT more than 1,500$.
    HOTween : a fast, type-safe, and powerful Unity tween engine.
    HOBlog: a development blog - mainly.
    Editor Undo Manager : a simple class to manage editor undos effectively


  9. Location
    Omiya, Japan (for 4 months)
    Posts
    356
    Should it not be possible to have a community driven wiki then?
    Someone just have to set one up and I'm sure many will contribute to it.
    Last edited by Virror; 04-10-2012 at 01:27 AM.
    Current game: Age of Settlement


  10. Location
    Austria, Europe
    Posts
    486
    why can't they just add a comments section to the docs like they have on php.net?! everyone could add clarifications and examples and everyone on the planet would benefit greatly!