how do you signal an area is entered when the area is in a different scene?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By SugarBeetle

Sorry, I’m a hardcore beginner in programming, but I keep having this problem across projects that I can’t solve. The problem is having 2 scenes and trying to signal that they enter each other’s areas to cause damage or score. In the context of this, I’ve made a spawner which spawns leaves, the leaves should disappear and give the player a score when they enter the player’s area. The code works when both are in the same scene but in my case, only the spawner itself is in the same scene as the player. I have tried using global variables, and instancing the leaves in the player script but I feel like I’m just not understanding and repeatedly getting it wrong. any help is welcomed. thank you!

:bust_in_silhouette: Reply From: Inces

You dont need to connect them to each other. Connect leaves signals to leaves themselves, and You can recognize collision inside the function :

func on_area_enetered(area) :
       if area is Player :
               area.score +=10

there are many methods to recognize collision. iskeyword is for checking classes, meaning if You introduced Player as classname Player. But You can also check for or area.get_parent().name, filename, has_method() and so on.

Advanced sollution for this problem would be to connect all signals within autoloaded script.