Hello,
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.
<C++ Error> UNUSEDSIGNAL
EventBus.gd:8
The code for the singleton is
extends Node
func _ready():
pass
# BATTLE SCENE SIGNALS
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'):
body.take_damage(1)
queue_free()
if body.is_in_group('Cell'):
EventBus.emit_signal("highlighted",self.position)
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)
print("test")
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!
Thanks!