04.assembling-game-missing-pieces

Adding the missing pieces

In this video, we add the sky, health bar, and open a room scene to flesh it out with a chest and pickups.

Troubleshooting

The health bar doesn’t stay on the screen

For the health bar to stay on the screen, it needs to be a child of the node name UILayer in your Scene dock.

I can’t see the health bar when running the game

Two lines are crossing in the editor’s viewport: a red and a green line.

The place where they cross represents the origin of the game level. For UI, it represents the top-left corner of the game’s window at runtime.

Your health bar should be placed below and to the right of that point to appear on the screen.

I can’t place objects exactly where I want, they move in big increments instead

In this series, we turned on grid snapping to precisely place some nodes. If you want to place some items freely, you first need to turn off grid snapping by clicking the magnet icon in the toolbar above the viewport.

You can also toggle grid snapping using the keyboard shortcut Shift+g.

Your questions

Why doesn’t the health bar move with the character?

The UIHealthBar stays at a fixed position on the screen when running the game.

This is due to its parent node, the UILayer.

This rendering layer does two things for us:

  1. It ensures the health bar always appears on top of everything else.
  2. It makes the health bar not follow the game’s camera.

You’ll see how we’ll get to use rendering layers in our projects later in the course.

In the next and last video, you’ll write your first line of code.