I made a system where if you walk up to an object and press the Interact input then a dialogue box shows up with something written there for each object. Basically what undertale and a lot of other games do. So the way I have it set up is that I have an area2d for every interactable object and when the player enteres the area 2d it sends a signal to the player node which sets the “can_interact” variable to true, and the same thing for when they exit but setting can_interact to false instead. If can interact is true and the player presses the interact input, then itll send a signal to the object to play the dialogue. But the game has no way of knowing what object’s area2d you’re in. So if you go into the area2d of any interactable object and press Interact, then itll show the dialogue for every interactable object.
(The script for the area 2d of every object. The only difference between objects is the dialogue file they play.)
(Player scripts for interacting)
(Node structure for 2 objects)
i ended up fixing it by handling everything in the area2d node without any signals to the player but please help me with my next issue making this system
Set a variable to represent the current interactable object.
The interaction signal should carry the source itself, and only the object stored in this variable should be triggered when the player interacts.