Proper way to change Sprite3D texture to ViewportTexture by code?

Godot Version

v4.2.2.stable.official [15073afe3]


I’ve created a radial progress bar with the help of a subViewport and a TextureProgressBar, but I can’t seem to figure out how to change the current texture of the Sprite3D to my desired ViewportTexture via code.

This is the code which updates the current sprite texture based on the player position:

func update_sprite_on_position(pos: Vector3):
	var distance = self.global_transform.origin.distance_to(pos)

	if distance >= 2:
		# just sets its current texture invisible
		interact_display.visible = false
	elif distance < 2 and distance > 1.4:
		# changes the current texture to a simple png file, works as expected
		interact_display.texture = DOT_TEXTURE
		interact_display.visible = true
	elif distance <= 1:
		#doesnt works
		interact_display.texture = INTERACTABLE_OBJECT
		interact_display.visible = true

The “INTERACTABLE_OBJECT” constant is the following:

const INTERACTABLE_OBJECT = preload("res://Assets/interactable_object.tres")

In practice, when I get close to the rigidBody this script belongs to, the sprite that is rendered is the DOT_TEXTURE still, even tho the texture property visibly changes in the remote tab in the editor.
At first, I thought it would be because of the viewport_path not being carried on the .tres file for some reason. I’m still not 100% sure if this is the case or not, but I don’t think Godot would change the sprite texture to the ViewportTexture without giving it the viewport_path (Can’t upload here yet, sorry).
And no, I checked if the problem was in the conditionals, but changing the “INTERACTABLE_OBJECT” to a simple placeholder texture held no bug, and worked as intended.
Any thoughts?
(P.S: my first time asking for help with my code, so go easy on me please :wink: )

Does it ever print closest? I wonder if you are getting close enough to trigger the if statement.