Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by freakly17 · Jan 31, 2019 at 07:58 PM · adsadmobinfinitegameoverrequest

admob repeating infinit times can't stop

hi, i can't stop the ad interstitial showing up after first time, it continuos at infinity even in the debug it's going crazy, i'm trying to show up only on death of the player, it mean at "GAME OVER", but it doesn't stop at that. i want to show up only 3-4 times after death or maybe every 5 minutes

 using System.Collections;
 using UnityEngine;
 using GoogleMobileAds.Api;
 
 public class AdScript : MonoBehaviour {
 
     InterstitialAd interstitial;
 
     private void Start()
     {
         RequestInterstitial();
     }
 
     void Update()
     {
         if (GameManager.isGameOver)
         {
             showInterstitialAd();
         }
     }
 
 
     public void showInterstitialAd()
     {
         if (interstitial.IsLoaded())
         {
             interstitial.Show();
         }
     }
 
     private void RequestInterstitial()
     {
 
 
 #if UNITY_ANDROID
             string adUnitId = "ca-app-pub-3940256099942544/1033173712";
 #elif UNITY_IOS
         string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE";
 #else
         string adUnitId = unexpected_platform";
          
 #endif
 
 
 
             interstitial = new InterstitialAd(adUnitId);
 
             interstitial.OnAdClosed += Interstitial_OnAdClosed;
 
 
             //AdRequest request = new AdRequest.Builder().Build();
 
             AdRequest request = new AdRequest.Builder()
                         .AddTestDevice(AdRequest.TestDeviceSimulator)
                         .AddTestDevice(SystemInfo.deviceUniqueIdentifier)
            .Build();
 
 
 
             interstitial.LoadAd(request);
 
             
         
     }
 
     private void Interstitial_OnAdClosed(object sender, System.EventArgs e)
     {
         RequestInterstitial();
     }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by LilGames · Jan 31, 2019 at 08:03 PM

Update executes EVERY FRAME! You should not be calling the ad from Update() but from somewhere else that only triggers ONCE when it's game over. I leave that to you to figure out where in all your game's scripts it is best to put that.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image freakly17 · Jan 31, 2019 at 08:05 PM 0
Share

ok i will try... i'm getting crazy xd

avatar image freakly17 · Jan 31, 2019 at 08:27 PM 0
Share

waaaaaaaaaaaaa i did it show up only once at death time, sincerely i was mad when you answer like this but now i understand why you said like that, i learned something new, i put in the Game$$anonymous$$anager, to find the object type :). But how i solve the problem with the fact that it's showing up every death, and that can be annoying, should i put a count on death( i don't know how) or put like show up every TOT time ? but the time is not good with the death of the player that is a variable that depends from the player, like if someone is good can be playing more than 1 $$anonymous$$ute and so he will get back again a AD.

avatar image LilGames freakly17 · Jan 31, 2019 at 09:27 PM 1
Share

:) I am glad you realized why my answer was not just code for you to copy-paste. Not every game is set up the same way and I can't guess where your code that sets isGameOver is... Glad you got this far.

For your next problem, you have two choices:

A. Control the ad frequency in-game by adding a counter variable to your Interstitial class. or B. Control it externally through Ad$$anonymous$$ob ad campaign settings.

For A, add a counter variable to the class, such as:

 private int adCounter = 4;

And in the showInterstitial class:

  public void showInterstitialAd()
      {
          if (interstitial.IsLoaded())
          {
 if(--adCounter == 0){
 adCounter = 4; // reset the counter
              interstitial.Show();
 }
          }
      }

I recommend #B, because it lets you change the ad frequency without ever publishing a new build and getting people to update their app. Ins$$anonymous$$d what you do is:

  1. Go to your Admob account

  2. Go to the App

  3. Click on the App Unit you want to edit

  4. Find the section called "Frequency Capping" and Enable it.

  5. Set how often you want to allow the ad to be displayed.

Unfortunately this method doesn't set it to counter based, (like "every 3 calls") type of frequency and ins$$anonymous$$d it is time based (like "no more than once every 2 $$anonymous$$utes") but the benefit of "outside the app" control is a good thing to have.

You could actually still combine both methods.

avatar image freakly17 LilGames · Feb 01, 2019 at 07:52 PM 0
Share

Yeah i did with Admob, thank you so much. I have published it. Thanks again.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

101 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Admob interstitial ad not showing up 1 Answer

Admob script help 0 Answers

Unity and Admob using latest Play Services Plugin 7 Answers

Admob reward player after watching video 0 Answers

Interstitial pause game on Android but not on iOS? 5 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges