0 votes

(sorry for bad english, using google translator)

I made a signal in my player's scene script that tells the map that its life reached 0, so it can queue free the Player and call the game over scene.

Player script example:

signal is_dead

func _on_dano_body_entered(body):

   life -= 1

if life <= 0:
   emit_signal("is_dead")

Map script:

onready var game_over = preload("res://GameOver.tscn")

func _on_Player_is_dead():
    var fim = game_over.instance()
    $Player.queue_free()
    add_child(fim)

On the first map it works perfectly, but on the second one apparently the signal is not being emitted, he's lifes reach 0 but nothing happens (the second map uses the same script as the first).

Thanks for read.

Godot version Godot 3.3
in Engine by (17 points)

Did you connect the signal again in the second map? Can you put a print statement before the emit_signal call and see if the function is called at all?

Thank you very much, I really hadn't connected it on the second map.

It's working now :D.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.