Search Unity

WebGL throttling effecting somethings but not others.

Discussion in 'Web' started by IAMBATMAN, Mar 22, 2017.

  1. IAMBATMAN

    IAMBATMAN

    Joined:
    Aug 14, 2015
    Posts:
    272
    I know the browser throttles inactive tabs, but my idle game involves pulling gold pieces with rigidbodies towards a chest to collect them. When they touch the chest they get destroyed.

    The gold pieces spawn every few seconds, and everything works fine when the tab is focused. But when unfocused it seems the chest stops pulling them, but they keep spawning. Making a big mess of goldpieces that don't get destroyed.

    So anything I can do?
     
  2. sirrus

    sirrus

    Joined:
    Jun 10, 2012
    Posts:
    250
    We built a custom component to handle logic when the app/tab loses focus via OnApplicationFocus

    In your case, perhaps you could write a handler to 'pause' the gold when the app loses focus but continue as normal when focus returns?
     
  3. IAMBATMAN

    IAMBATMAN

    Joined:
    Aug 14, 2015
    Posts:
    272
    It's ok I solved it by multiplying by time.fixeddeltatime when add a force to the gold to bring it to the chest :)

    This way the player can still get gold while away