Hello, I'm quite new to all of this and need some help. I'm building a small frogger-like game and I created a "enemy" array that moves right whenever any of the keybinds are touched. Once it exits the screen width it moves back to the spawning area. The problem is that once the function activates it doesn't stop, which essentially freezes the enemy just off the left side of the screen.

here's a link to the code that seems to be causing the issue https://github.com/manpaka/debugRepo/tree/main/froggerv1/enemy.gd

the organization is a little messy when it comes to assets but that shouldn't be an issue as I've titled the files clearly enough to read.

I believe in the flip flop function you have to set lastPosition as well after setting the x back:

func flipFlop():
	if position.x >= 1216:
		position.x = -64
		lastPosition = position

That does remove the repeating loop, but the enemy is still being locked in place at -64, essentially removing the movement function.

You might also need:

targetPosition = position

After the last position call in flop flop.

Thank you, it seems to all be working now.

2 years later