Need advertisements appearing every 5 minutes
So i am basically making a runner project and i want to show ads every 5 minutes whatever the scenes are.For example i have been in the first scene for 30 seconds when i changed the scene time must continue from the 30 seconds.And at the end of the 5 minutes ad must be appear but there will be one more condition and that is death condition.I dont want ads to appear while player plays the runner game so ad must appear when death occurs(isDead = true).For example the player plays the game for 7 minutes without dying ad wont appear after 5 minutes.It will appear after he dies but time must be minimum 5 minutes.So i tried to do that with this piece of code but it doesnt work properly.I will be very appreciated if you help me cuz i am so close to finish my project.
// Update is called once per frame
void Update () {
if (isDead)
return;
if (score >= scoreToNextLevel)
LevelUp ();
score += Time.deltaTime * difficultyLevel * 100;
scoreText.text = ((int)score).ToString ();
timer -= Time.deltaTime; ////5 dakikada bir reklam
ShowAd ();
}
public void ShowAd() //5 dakikada bir reklam
{
if (Advertisement.IsReady() && Time.time % 5f <= 0.01f && isDead == true)
{
Advertisement.Show ("video");
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612174822im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
FindObjectsOfType not find all objects and code not do anything. 0 Answers
Coroutines Madness (); 1 Answer
loop for perimeter of game board 0 Answers
How to stop this infinite loop 1 Answer