godot: Using Viewport Texture causes "node not found" error / "Cannot get path of node as it is not in a scene tree"


Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.


Godot version: v3.0.rc3.official

OS/device including version: Ubuntu 16.04

Issue description: I’m using the canvas 2D drawing functions to create a texture and then using that texture on other nodes. Instancing a 2D scene that uses local viewport textures causes runtime errors in the Output and Debugger panes but the project still runs correctly. The errors are:

Node not found: Viewport ViewportTexture: Path to node is invalid

The errors show in the Output pane when the parent scene is loaded and in the Debugger when the project runs. It makes testing tedious because I never know if the error in the Debugger is real or not.

I’m not sure if my node setup is correct for what I’m trying to accomplish but it works.

Steps to reproduce: I’ve attached a project that repros the problem.

  • Open the project, open the main scene, and you should see the errors in the Output pane
  • Run the project and you should see the errors in the Debugger pane

Minimal reproduction project: node-not-found-example.zip

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 5
  • Comments: 29 (19 by maintainers)

Most upvoted comments

Just discovered that if the Viewport node is moved above the nodes that use its texture then the issue goes away. Not sure if it’s a bug or not.

I found that error is gone if I moved Viewport node to above Sprite3D node which uses ViewportTexture

Setting Local to Scene doesn’t prevent the issue for me. Only moving the Viewport node above the nodes that use its texture avoids it for me.

I was facing the same issue. I tried everything in Godot 3.4 and the Viewport issue just doesn’t resolve. I tried the suggestion where I make the Viewport the parent of the Sprite3D. But that also had issues. It stopped showing me the viewport contents if I was reusing the “Scene with the Viewport” in other nested scenes. Still don’t know how to fix it.

I managed to make the error disappear not by making Viewport a parent of Sprite3D, but by making Viewport a sibling that comes before Sprite3D on scene tree. One thing I was missing though is that you have to reassign ViewPortTexture on Sprite3D after the change.

I don’t really know why, I’m kinda new on Godot 😄 But it did make the errors disappear

@gustavopergola when i do that, it somehow outputs a different error instead: E 0:00:08:0528 highlight.gd:19 @ _init(): Condition “proxy.is_valid()” is true. <C++ Source> scene\main\viewport.cpp:89 @ ViewportTexture::setup_local_to_scene()

I am getting this sort of error message as well. What I have noticed is that the viewport texture seems to work fine when running the project in the editor, but on exported builds, the texture is garbled or pitch black depending on the graphics hardware I’ve tested on. Even if I made sure that the subviewport loads before my nodes using the texture in the hierarchy.

As gu-fan points out, you can work-around having to place the SubViewport above the node that needs the ViewportTexture if you set the texture in code using i.e.

func _ready():
    $Sprite3D.texture = $SubViewport.get_texture();

Doing this seems to get rid of the error message described above, but my ViewportTexture is still corrupted. UPDATE: Apparently the corruption only happens with the vulkan renderers. The GLES2 version reports errors but works just fine in builds. There’s probably some other funny business happening that causes the issue I’m seeing.

@Nekuromu 3.5.rc7 has a Label3D node, so you don’t need to use a Viewport anymore for that. It should be safe to upgrade now, but make sure to backup your project files before just in case.

same as prev comment: If you set viewport texture in editor it will show node not found. If you set viewport by code, like

var vwtex = ViewportTexture.new() vwtex.viewport_path = NodePath(‘%OffViewport’)

will show

E 0:00:07.821 get_height: Viewport Texture must be set to use it. <C++ Error> Condition “!vp” is true. Returned: 0 <C++ Source> scene/main/viewport.cpp:105 @ get_height()

Update:

I found as document says I should use spr.texture = offvw.get_texture() which works and no error output

I am still having this issue even if the viewport texture resource is local to scene on 01e24447a