Setting viewport texture to a viewport?

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

Here is what I’m currently trying:

var sprite3d = Sprite3D.new()
var viewport = Viewport.new() 
add_child(viewport)
var viewport_texture = ViewportTexture.new()
viewport_texture.set_viewport_path_in_scene(viewport.get_path())
sprite3d.texture = viewport_texture

However I’m getting the following error:

0:00:05:0418 - Condition ' !vp ' is true. returned: Size2()
----------
Type:Error
Description: 
Time: 0:00:05:0418
C Error: Condition ' !vp ' is true. returned: Size2()
C Source: scene\main\viewport.cpp:106
C Function: ViewportTexture::get_size

Makes me think that maybe the viewport_texture isn’t actually using the viewport and isn’t displaying any texture. Any help appreciated.

You never assign the viewport_texture to anything. How is the viewport meant to know, that it should use it?

Have your read this?

Banbury | 2018-03-18 08:10

I updated it but I didn’t think that adding the texture to a sprite was relevant, I would still get the same error

jarodwr | 2018-03-18 12:23

The problem here is that the viewport texture doesn’t know what the node path is relative to, and as far as I can tell the only thing configuring that is the packed scene system. Not sure this can be fixed without modifying the source code.

Pieter-Jan Briers | 2018-03-18 14:40