The Godot Community Forums are back up and running! Please read the the announcement post for important information on what happened. Thanks!

How can I fix a Viewport to display 2D inside a 3D scene

I am sure there has been many questions and answers around this subject. Few issues about in the github. So this is where I start. Programming a HUD. I created the HUD components in a image processing software such as Photoshop. Health and Mana Progress bars. Basically my current project is somewhat at a stand-still. I search and got a bit of a headache. Transitioning to a new programming language isnt easy for me.

So this is the HUD inside the Viewport

And this is what it looks like without the Viewport

The main node has a script attached. Basic Input testing out progress bars

What do I need to do. Write more code.. lovely..
$Viewport.something.something() ??

It's 3:30 in the morning I been at this all day.

Comments

  • TwistedTwiglegTwistedTwigleg Posts: 3,141Admin

    Out of curiosity, why are you putting the HUD inside a Viewport node? If you want it rendered on top of the 3D world, you can either just use a Control node as the parent, or if you want to control where it sits relative to the other Control nodes you can use a CanvasLayer node.

    Looking at the pictures provided, it doesn't appear that you have a node to display the contents of the Viewport. You will need to use a node to show the viewport contents, like a Sprite2D node or a TextureRect node. You can set the texture to a Viewport texture in the texture dropdown or you can use get_node("TextureRect").texture = get_node("Viewport").get_texture() if you want to assign the texture through code. Another thing to check is that the Viewport size isn't set to (0, 0), which is its size by default.

  • I saw somewhere on the net that they used a viewport to for relative positionings of where the viewport is intitalized . I just do not understand how to even render a 3D perspective. And I have stumbled up CanvasLayers . I parented the HUD_Container with Control. Im not sure whats next. If there is a solution to the question or realative content.

    The is very new to me.

  • TwistedTwiglegTwistedTwigleg Posts: 3,141Admin

    @Asmosis said:
    ... Im not sure whats next. If there is a solution to the question or realative content.

    What do you mean? I don't mind trying to help but I am confused on what the issue is. Is the HUD not drawing over the screen or not drawing how you would expect?

  • I put all bars and hud_con inside a blank Control. The solutions was adding a camera.
    -- >:(

  • TwistedTwiglegTwistedTwigleg Posts: 3,141Admin

    I’m glad you found the solution! :)

  • extends KinematicBody

    I created a individual scene for the player as a
    KinematicBody - CollisionShape and MeshInstance

    Next.... extends Node # MainNode attached to WorldContext

    I wanted the camera to move with the mouse. Not the best solution.. I think I might have to initialize the before the change of the camera view.

  • Scenes and Objects

  • JatzJatz Posts: 0Member
    edited September 18
  • TwistedTwiglegTwistedTwigleg Posts: 3,141Admin

    (Deleted duplicate posts from @Jatz - probably network/server lag or something)

Sign In or Register to comment.