Hello,
I just recently got basic Unity ads to work at the end of every death. And now I’m trying to make them show up on every 5th death so that it doesn’t bombard the user.
Would anyone be able to help me with this?
Thanks in advanced! ![]()
Hello,
I just recently got basic Unity ads to work at the end of every death. And now I’m trying to make them show up on every 5th death so that it doesn’t bombard the user.
Would anyone be able to help me with this?
Thanks in advanced! ![]()
Hello @jrivis
Hope this code helps.
...
private int deadcount; // Player dead count.
void Start()
{
deadcount=0;
}
public void OnDead()
{
// If player deads first time we show the ad and add 1 to our counter.
if(deadcount==0)
{
ShowAd();
deadcount+=1;
}
// We reset counter after 5 deads
else if (deadcount==4)
{
deadcount=0;
}
}
Regards,
Hello @Salazar ,
Thanks heaps for getting back to me ![]()
I tried adding this code you have given me to my gameover script. But it seemed to have made the ads not load at all.
I could be inserting it into the wrong section though ![]()
I have uploaded my current Gameover script that loads my ads every gameover, just for reference if that may help? ![]()
2334239–157706–GameOver.cs (2.49 KB)
Hello @jrivis ,
Having two monobehaviour classes on same script is not a good practice i think. (ref.)
I am seperating my gamemanager script and admanager script and using C# singleton feature to communicate each other.
You should check scripting with unity tutorials. www.unity3d.com
I am not a pro at coding, so I dont want to miss guide you at the very basics.
Regards,