In my game the player can drop tiles to build a tower. The tiles are RigidBody2D nodes and hence use the physics engine. The tiles are created on clicking LMB and are instanced as children of my level. Dropping tiles should only be possible when the prior tile is on the ground and no longer moving.
So I want my tiles after entering sleep mode to emit a signal to my level node to make it possible to drop the next tile. The signal should only be emitted once as soon as the tile comes to rest. It is possible that later tiles force prior tiles to move again and at this point the "old" tiles should NOT emit this signal again.
The signal code in my tile.gd:
print ("Going to sleep now! (TILE)")
The code in my level.gd:
if Input.is_action_pressed("left_mouse_button") and timer.is_stopped():
if dropped_tile_asleep == true:
dropped_tile.connect("sleeping_now", self, "on_tile_is_sleeping")
print ("OK, good night! (LEVEL)")
dropped_tile_asleep = true
The signal works, but the oneshot thing does not. The print entries tell me, that the signal also fires again when tiles are moved by other tiles. Did I misunderstand how CONNECT_ONESHOT works or is my code wrong?
Thx for reading