Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Zylo_X |
Hello Community
i have a simple question why signal in this code is not working ?
i have a ship shoot laser ( area 2d) to enemy (rigidbody 2d) , the enemy must disappear and a signal sent to main node in order to give player points
the enemy disappear but the signal doesn’t connect to main node
even though i added laser as an instance child scene to main node (node 2d)
laser script :
extends Area2D
signal score
export var Laser_speed = 1000
var Laser_direction = Vector2(0,-1)
func _process(delta):
self.position += Laser_direction * Laser_speed *delta
func _on_VisibilityNotifier2D_screen_exited():
queue_free()
func _on_Laser_2_body_entered(body):
body.queue_free()
queue_free()
emit_signal(“score”)
i connected the signal to a function in main script to test it:
func _on_Laser_2_score():
print(“Success”)
but nothing happen …