Based on the error, it sounds like the ViewportContainer is having issues getting the Viewport and/or the Sprite3D is having difficulties getting the texture from the Viewport. Probably the NodePath to the Viewport texture in the Sprite3D is not setup correctly, as the path being passed (in line 2
of the error) is trying to access Viewport
as a direct child of the node and the node isn't there.
To fix it, I think all you'd need to do is delete the ViewportTexture in the Sprite3D, and then make a new ViewportTexture in the editor and assign it to the Viewport.
In this case though, I do not think you need a ViewportContainer if you are using a Sprite3D to display the healthbar. You should be able to use a setup like this:
Then set own world
to true
in the Viewport and set it's size so it's large enough to show the entire ProgressBar node. You might also want to enable transparent bg
as well.
Then in the texture
property of the Sprite3D you can create a new ViewportTexture and set it to the Viewport. However, I've found that doing it through code can be a bit more reliable than in the editor:
extends Sprite3D
func _ready():
texture = get_node("Viewport").get_texture()