Viewport texture to sprite not updating

Godot Version

3.5

Question

I am trying to display a 3D camera viewport texture on a 2D sprite. The sprite shows the correct texture on starting, but then doesn’t update every frame to show what the camera is showing. I have tried passing the texture to a TextureRect too but the result is the same.

extends Sprite
 
onready var viewport = get_parent().get_node("player/Viewport")

func _process(delta):
 	set_texture(viewport.get_texture())

What am I doing wrong?

I’ve done some more research and think it is related to this bug where viewport textures are not updated. ViewportTextures do not update and draw · Issue #83682 · godotengine/godot · GitHub

Still no closer to finding an answer or a workaround.

I have solved the problem, mostly by following the viewport and camera structure shown in this tutorial SubViewport In Godot - Complete Guide - GameDev Academy.

The entire 3D world is put as a child of the Viewport. Then use a TextureRect and set the texture to “New Viewport Texture” > said viewport in the the inspector. I don’t really understand why my solution didn’t work before, but this is certainly easier!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.