0 votes

I want to have a 2D art background in a 3D world.

I copied everything - all the codes and the properties from the 2D in 3D demo in the asset store but i can't seem to translate it at all in my project.

This is my node structure

+ game (Node)
|-- (other nodes of the project here)
|-- viewportQuad (MeshInstance)
|-- Viewport
| |-- background (2D Node scene)

< background 2D Node scene >

+ background (2D Node)
|-- sprite (Sprite)
| |-- bgLayer1 (Sprite)
| |-- bgLayer2 (Sprite)
| |-- bgLayer3 (Sprite)
| |-- bgLayer4 (Sprite)

I tried to extract the nodes of the background scene and made the sprites a direct child of the Viewport node but still no luck. I still don't see anything.

This is the script i copied from the demo.

var viewport = getnode("Viewport")
setclearmode(Viewport.CLEARMODEONLYNEXTFRAME) yield(gettree(), "idleframe")
yield(gettree(), "idleframe") getnode("viewportQuad").materialoverride.albedotexture = viewport.gettexture()

It's basically 5 lines of code only so it's supposed to be straightforward. What am i missing here?

print(viewport.get_texture()) or print_debug(viewport.get_texture()) doesn't help. It just shows you something like a resource (i don't know what it is.) Like: [ViewportTexture:1207]
^ Idk how to use that for investigating or debugging.

Maybe there is a different way of seeing a viewport's texture to debug this?

My Env:
Godot 3.1.1

Demo Env:
Godot 3.0

asked Jun 6 in Engine by jagc (89 points)
edited Jun 7 by jagc

Not even comments for this one? anyone?

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.