![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | dany_pitre |
Hi ! I’ve been trying to make an enemy spawner and have a big issue.
The way my system works is that if the player is the same type as my enemy, it can youch it and it will increase his score. If it’s not the same type, it will kill him. Each time the player enters the area of the enemy, the enemy emits a signal that will tell the player to check if it’s the same type and do the action to increase score or kill him.
the problem that I have is that if the player reach the score of 1, my player can touch any enemy and it will not increase the score or kill the player, but only queue_free the enemy… i’ve been looking to fix this bug for a few hours and dont have any idea of the issue since i’m new to godot and coding in general.
Here is my code for the player’s scipt:
func _on_0_white_check() → void:
if type == 0:
score += 1
print(“points” + str(score))
else:
die()
func _on_0_red_check() → void:
if type == 1:
score += 1
print(“points” + str(score))
else:
die()
func _on_0_yellow_check() → void:
if type == 2:
score += 1
print(“points” + str(score))
else:
die()
func _on_0_blue_check() → void:
if type == 3:
score += 1
print(“points” + str(score))
else:
die()
Here is my code in my enemy’s script:
func _on_Area2D_body_entered(body: Node) → void:
if type == 0:
emit_signal(“white_check”)
elif type == 1:
emit_signal(“red_check”)
elif type == 2:
emit_signal(“yellow_check”)
elif type == 3:
emit_signal(“blue_check”)
queue_free()
If someone has an idea… please help me ! Thanks a lot