Godot dont pause when ad is being displayed

Godot 3.5

Hello everyone,

i finished my HTML5 game and i want to place it on HTML5 game portals such as Poki. However they require you to implement their SDK. I tried Poki’s SDK the only problem i keep having and really cant solve is that when an ad plays the game dont pause. You still can press buttons and control the player and the sound isnt muted.

Here is my code:
func on_next_button_pressed():
$“/root/LevelManager”.increment_level()
get_tree().paused = true
PokiSDK.gameplayStop()
PokiSDK.commercialBreak()
PokiSDK.gameplayStart()
get_tree().paused = false

I think when PokiSDK.commercialBreak() is being run it doesnt wait till the ad is being finished playing and goes on to running the other lines. Is there a way to pause the game until the ad is finished ?

Thanks in advance,

Do you have your “commercial_break_done” signal connected?

Shouldn’t you unpause there?

Docs: Godot - Poki Developer Guide

1 Like

What HK said.

func _ready():
    PokiSDK.commercial_break_done.connect(_on_commercial_break_done)

func on_next_button_pressed():
    $“/root/LevelManager”.increment_level()
    get_tree().paused = true
    PokiSDK.gameplayStop()
    PokiSDK.commercialBreak()

func _on_commercial_break_done(response):
    PokiSDK.gameplayStart()
    get_tree().paused = false

Source: Godot - Poki Developer Guide

Edit: lmao I didn’t even notice you referenced same page HK, I’m half-asleep. Welp w/e

1 Like

Thank you guys both @HKLabs @alextheukrainian .

I struggled with this for weeks and the answer was just right in front of me :smiling_face_with_tear:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.