Skip to content

Add health bar example #19457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

GitGhillie
Copy link
Contributor

Objective

Show a way to create a health bar which follows a 3D object around.

Solution

  • Created example
  • Using camera.world_to_viewport() to position the UI node

Testing

  • cargo run --example healthbar

Showcase

image

Notes

  • The text showing the health is taking up a part of the health bar and I'm not sure how to fix it
  • Created during the Rustweek 2025 unconf, thanks again all 😄 cc @inodentry

@janhohenheim janhohenheim added C-Examples An addition or correction to our examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes labels Jun 2, 2025
@GitGhillie
Copy link
Contributor Author

GitGhillie commented Jun 7, 2025

Finally had the time to implement the feedback, thanks for the tips!

This is what it looks like currently:
image

There is more that could be improved based on what bevy_ui_anchor is doing, but maybe it's also a signal that it should be upstreamed. I'll leave that call to the experts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Examples An addition or correction to our examples D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants