I’ve been trying to code certain blocks in a 2D game, but I can’t figure out how to do a specific task that isn’t really mentioned. How would I send a signal to another scene and from that scene I make a “if received” code? I’m asking because what if the CharacterBody2D touched a block and then the block has to send a signal to that to make it do something.
It’s a handful, but nevertheless, I don’t know how to code this. If anyone does know any help is appreciated. Thank you!
Well, it’s all about sending signals between the scenes.
If your “block” is a scene of Area2D type, you can subscribe to its body_entered signal from your CharacterBody2D scene and have it do something.
This example is mentioned in the linked document as well.
For example, an Area2D representing a coin emits a body_entered signal whenever the player’s physics body enters its collision shape, allowing you to know when the player collected it.