Hi! I'm trying to create a topdown shooter zombie game. In my World (main) scene, I have created several nodes like "Survivors", "Bullets", and "Enemies" where I would add my zombie scenes as a child of the Enemies node in the ready function. The Zombie scene has a detection radius set to 150 and I want it so that if the player enters this radius, the zombie would start going towards the player and its detection radius would increase to 300. But the problem is, when I spawn some zombies, and I enter the radius of one zombie, all of them would increase their radius to 300 even though I didn't enter the detection radius of the others. This is the code in my world scene:
onready var Zombie = preload("res://Scenes/Zombie.tscn")
for i in range(num):
var Z = Zombie.instance()
Z.global_position = Vector2(rand_range(300, 600), rand_range(300, 600))
And this is my script in my zombie scene: (However I will not include the part where the zombie goes towards the player because I have no problem with that.)
if target: #target is whoever entered the DetectionRadius
What I have tried so far is that I made a function called "target_seen" in the zombie scene and I placed the expansion of the radius of DetectionRadius code there only to see the same result. I'm a beginner in Godot and I started learning last 3 weeks and this is my first time asking in the site. Thank you!