Why would world_to_map() or map_to_world() be causing an infinite loop?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By xofox

So I’m trying to get something to reference position in GDScript but whenever I reference the methods world_to_map() or map_to_world() and I run the script my program seems to enter an infinite loop and has to be force closed.

func BasicMovement():

if Input.is_key_pressed(KEY_A):
	goalPosition += Vector2(-1,0)
	turnCount = turnCount + 1
elif Input.is_key_pressed(KEY_D):
	goalPosition += Vector2(1,0)
	turnCount = turnCount + 1
if Input.is_key_pressed(KEY_W):
	goalPosition += Vector2(0,-1)
	turnCount = turnCount + 1
elif Input.is_key_pressed(KEY_S):
	goalPosition += Vector2(0,1)
	turnCount = turnCount + 1


func SnapToGrid():

What is here that screams infinite loop to you guys?

Nothing looks like an infitite loop here, but you should investigate where that infinite loop actually happens. Maybe it’s not where you think it is. Try pausing the debugger when that happens and see what the script is doing at this time.
If it doesn’t work, try putting two print statements around the location you believe that loop is happening.

Zylann | 2019-03-11 13:42