Unity Ads with multiplayer games

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

The pausing is not optional here unfortunately, so I would recommend reconnecting after the ad has finished / gameplay has resumed.

oh, I see. Well that’s unfortunate. Thanks! I’ll do that :slight_smile:

For clarity, you are seeing sockets being closed after only 30 seconds while an ad is shown?

Unity disconnects my Google Play real-time multiplayer matches when a UnityAd is shown, or a user purchases something.

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?

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.

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 ?

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.

thanks for the answers.
edit: Do you know if google ads use the same pause system ?

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:
https://www.youtube.com/watch?v=b_-LePudm4c
(@1:05)

With both you can see the Unity-App Suspend, and the other app pop into view.