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 on0whitecheck() -> void:
if type == 0:
score += 1
print("points" + str(score))
else:
die()
func on0redcheck() -> void:
if type == 1:
score += 1
print("points" + str(score))
else:
die()
func on0yellowcheck() -> void:
if type == 2:
score += 1
print("points" + str(score))
else:
die()
func on0bluecheck() -> void:
if type == 3:
score += 1
print("points" + str(score))
else:
die()
Here is my code in my enemy's script:
func onArea2Dbodyentered(body: Node) -> void:
if type == 0:
emitsignal("whitecheck")
elif type == 1:
emitsignal("redcheck")
elif type == 2:
emitsignal("yellowcheck")
elif type == 3:
emitsignal("bluecheck")
queue_free()
If someone has an idea... please help me ! Thanks a lot :)