Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity Ads with multiplayer games

Discussion in 'Unity Ads & User Acquisition' started by Rafael-Barbosa, Feb 1, 2019.

  1. Rafael-Barbosa

    Rafael-Barbosa

    Joined:
    Apr 14, 2013
    Posts:
    288
    Hey, I did some digging and all the threads about this seem to not have a definite answer/are quite old.

    I'm working on a mobile game where the users are connected to a server using socket.io (on a NodeJS server), this means that I need an active connection or else the connection is considered as closed eg: Player is afk, so let's disconnect him.

    Unity Ads seems to pause the unity application, and that makes the player be inactive for quite a while which get's him disconnected. I need a workaround for this as that options.paused = false thing seems to not do anything. What I was thinking is: let the player be disconnected from the server and just reconnect him afterwards (it's not a realtime multiplayer game, so that doesn't really bother me), or, if there is a better way, I would like to not pause the game while the Ad is being shown, is this possible?

    Thanks!

    Raf
     
  2. mikaisomaa

    mikaisomaa

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    365
    The pausing is not optional here unfortunately, so I would recommend reconnecting after the ad has finished / gameplay has resumed.
     
  3. Rafael-Barbosa

    Rafael-Barbosa

    Joined:
    Apr 14, 2013
    Posts:
    288
    oh, I see. Well that's unfortunate. Thanks! I'll do that :)
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    For clarity, you are seeing sockets being closed after only 30 seconds while an ad is shown?
     
  5. FamishedMammal

    FamishedMammal

    Joined:
    Nov 3, 2015
    Posts:
    113
    Unity disconnects my Google Play real-time multiplayer matches when a UnityAd is shown, or a user purchases something.
     
  6. Paradoks

    Paradoks

    Joined:
    Oct 13, 2009
    Posts:
    436
    Hello, I have the same problem for my multiplayer game.
    I would like to know if the '30 seconds' mentioned above by @JeffDUnity3D is the exact duration of the pause or if it can vary?
     
  7. SF_FrankvHoof

    SF_FrankvHoof

    Joined:
    Apr 1, 2022
    Posts:
    780
    That 30 seconds is likely a default timeout for the socket. Not necessarily related to the Ad (though many ads might be close to that 30s mark).
    There will never be an 'exact duration'. Some players might skip the ad early, some might open the AppStore-link from the Ad.
     
  8. Paradoks

    Paradoks

    Joined:
    Oct 13, 2009
    Posts:
    436
    above mikaisomaa said:
    So i thought it was unity ads that was pausing the app during the ads display.
    So my question is: if it is the case, unity pausing while displaying ad, is that pause duration fixed ?
     
  9. SF_FrankvHoof

    SF_FrankvHoof

    Joined:
    Apr 1, 2022
    Posts:
    780

    Correct. However, it will basically pause the entire app and start up another "Ad-App" on top of it.

    No, because it depends on how long the "Ad-App" is visible. Which in itself depends on whether the user skips, 'clicks' on the ad, etc.
     
  10. Paradoks

    Paradoks

    Joined:
    Oct 13, 2009
    Posts:
    436
    thanks for the answers.
    edit: Do you know if google ads use the same pause system ?
     
  11. SF_FrankvHoof

    SF_FrankvHoof

    Joined:
    Apr 1, 2022
    Posts:
    780
    Yes. Both rely on native applications to do the actual ad-serving.

    Edit: Of course this only happens for full-screen ads. Banner-ads simply render on top of your app (with your Unity-game reserving space for it).

    Here's an example of a Unity-Ad: https://www.youtube.com/shorts/DrN_tHQBLB4
    And here's Google AdMob:
    (@1:05)

    With both you can see the Unity-App Suspend, and the other app pop into view.
     
    Last edited: Feb 7, 2023