content

Trying to figure out why my teleportation code resulted in the player not being able to move. I wrote the following code:

func teleport_to(target: Node2D):
	var level = target.get_parent()

	# Move the entire rig
	self.reparent(level)
	self.global_position = target.global_position

	# Move the player
	player.position = Vector2.ZERO
	if "required_facing" in target:
		var spawn_facing = Types.flip_facing(target.required_facing)
		player.stand(spawn_facing)
		player.last_facing = spawn_facing

	# Update the camera
	camera.calculate_limits()

As it turns out, _physics_process was no longer being called on the player. I'm not really sure why this is happening, but calling set_physics_process(true) fixes the issue:

func teleport_to(target: Node2D):
	# ...

	# Move the player
	player.position = Vector2.ZERO
	set_physics_process(true)

	# ...

meta

created:

backlinks: _physics_process(_delta) doesn't work after teleporting voluntary commitment logs

commit: 7a11fe02