Viewport texture goes black after Play

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

I am making a shooter, and I want my vehicle to have a cool 3D HUD. Instead of having a main hud that is displayed on top. I set it up, You can see it in the editor. I hit play, does not work.

It fails to save too. I know the viewport texture can display to the mesh. I can see it in scene. What is turning my texture black?

Here’s the source code.

:bust_in_silhouette: Reply From: lavaduder

Okay so I fixed it. by changing the Meshinstance to a Sprite3D.

(Not sure Why this happens still. So I’m not going to say this is the answer. So feel free to explain.)

This is really the one and only thing that helped me, thank you so much <33

(still helpful after 4 years lmao)

Majsek | 2022-01-27 03:18

:bust_in_silhouette: Reply From: Throckmorpheus

If the shader you’re using isn’t set to be local to the scene, the Viewport texture will work in the editor (for some reason? I can’t tell why) but at runtime it’ll try to find the viewport from the root of the tree, making the path wrong. If you set both the Viewport Texture and shader to be local to the scene, it’ll work.

(ik this is three years old but im putting it here so the next person who needs to do this can find the answer on google instead of going round in circles being stuck for two hours like i did)

Did not work for me, but maybe I am doing something different.

I am digging in this for more than an hour and it just doesn’t make any sense. I tried to change the MeshInstance to Sprite3D though and it works perfectly, even fitted the size of the Viewport.

This is 4 years old now and still confusing.

Majsek | 2022-01-27 03:18