Hello I've just began using Godot and I must say its extremely fun. I stumbled upon a problem where I want to increment my variable every one seconds by 1 but its increasing by 60 or more.

Here is the code:

func behavior(delta):

	if firstSpawn == false:
		self.position.y = 3000;
	elif checkFirst:
		self.position.y = 1;
		checkFirst = false;
		

	if alive and spawns > 0:
		if self.position.y > 1300:
			$Animation.show();
			yield(get_node("Animation/Explosion"), "animation_finished");
			$Animation.hide();
			alive = false;
			firstSpawn = true;
		else:
			self.position.y += 3000 * delta;
	else:
		yield(get_tree().create_timer(1), "timeout");
		spawns -= 1;
		self.position.y = 5;
		alive = true;
		
	
	if spawns < 1:
		yield(get_tree().create_timer(0.2), "timeout")
		get_tree().change_scene("res://Game.tscn");	

What you are probably doing is calling the same function every frame. What you want to do is call the function once, and put the yield function in a loop.

@fire7side said: What you are probably doing is calling the same function every frame. What you want to do is call the function once, and put the yield function in a loop.

Thank you very much. I fixed it by creating my own time functions for animation and explosions. But next time when I use yield I will do what you said.

a year later