Hello. I'm hoping someone can help me. I have a scene called Main. Main instances two scenes, Player and Mob.
Mob is a RigidBody2D with an Area2D node (DeathArea) which has a child CollisionShape2D node (DeathCollision):
-Mob
--DeathArea
---DeathCollision
Within the script of Mob, I have the following:
signal infected
func _on_DeathArea_area_entered(area):
if area.get_name() == 'Player':
print("die")
emit_signal("infected")
If I test it, I get "die" in the output and if I put a stop on emit_signal("infected"), the game interrupts at this line when the correct collision happens. So far, so good.
The Main scene looks something like this:
-Main
--Player
--Mob
If I click on Mob in the Main scene and click on Node, I can see the Infected() signal. I connect this signal to the Main script. For testing, I have the following set in Main.gd:
func _on_Mob_infected():
print("Player is infected")
When I test collisions now, I still get "die" in the output but I do not get "Player is infected" which tells me that Main.gd is not seeing the signal.
I've tried a bunch of different things here, but I can't seem to get the signal recognized. The way this is set up is very similar (or exactly the same) as the hit() signal from the Player in the My First Game tutorial from Godot.
I have a few signals going back and forth between scenes that are instanced in Main and I'd really like to take advantage passing around information (unless this isn't best practice).
Can someone help me with suggestions on what to troubleshoot or what to try?