Signal not emitted when using an autoloaded script.

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


I am trying to use a singlton to manage signals emitted by enemy bullets in my game when they collide with a TileMap. However, I am getting the error

**W 0:00:00.857 The signal ‘highlighted’ is declared but never emitted.

The code for the singleton is

extends Node

func _ready():


signal highlighted(ebpos)

With the signals being emitted in the EnemyBullet scene as such

func _on_EnemyBullet_body_entered(body):
if body.is_in_group('Player'):
if body.is_in_group('Cell'):
	print("collision test")

Here the the collision test is printing so the signal should be emitted, yet I continuously get the error.

For reference the signal should be then connected in the BattleStage scene with the following code

func check_for_highlight():
if self.has_node("res://Battlescreen/Scenes/EnemyBullet.tscn"):
	EventBus.connect("highlighted", self, "highlight_cell")

func highlight_cell(ebpos):
	var tile_pos = ebpos.snapped(Vector2(116,76))
	var tilemap_pos = $Game_grid.world_to_map(tile_pos)
	var tx = tilemap_pos.x
	var ty = tilemap_pos.y
	$Game_grid.set_cell(tx,ty+5, 1)

I tried this before without the singleton and it worked except I was experiencing problems which I couldn’t solve and assumed maybe using a singleton to manage the signals of nonpermanent scenes/nodes could solve my problems, but I am not sure why the signal is not being emitted.

If you could help me I would appreciate it!


How do you access the EventBus singleton? I assume your scripts do this:
var EventBus = $"/root/EventBus"

I’m not seeing any problem with the code you’ve shared. Mind sharing the complete scripts?

Bernard Cloutier | 2020-09-30 14:53

Hi, thanks for your comment. I am still getting the error that the signal is never emitted, but I am getting the highlight I was looking for, so I guess it is. The only problem is now the tilemap itself isn’t really working properly so I have to investigate that a bit.


atarias1 | 2020-10-01 08:40