Why won't my enemy spawn

I have this issue where I need a enemy to be spawn after the player walks into a area they are not suppose to twice but it does not seem to work idk the issue it may be super simple

var farm = preload("res://scenes/farmer.tscn")
var num : int=0

func spawn(pos):
	var instance = farm.instantiate()
	instance.position = pos
	add_child(instance)
func spawn_num():
	num+=1
	if num>2:
		spawn(Vector2(0,0))

how do you have this set up?

is spawn_num hooked up to an area2D entered signal or something?
might be worth checking if the function is actually getting called, it definitely happened to me before that my collision layers were messed up without noticing

1 Like

yes it is set up with area2d entered and I know its getting called because the num int does get bigger I used print(num) to check

I now know some more of what’s happening
1.I can’t spawn in other methods other then ready and process
2.num does update in process but does in spawn_num it just says 0 ever

I used more signals instead of calling a function from another script and it worked