#Questions about 2DCamera, the world, viewport and the UI

6 messages · Page 1 of 1 (latest)

earnest tide
#

Hello, I have some trouble understanding how these concepts works together and how can I design a game with the simplest design possible.
As I can't really start to draw things on screen without understand how all of these interact.

I'll proceed what I want to do.

  1. creating a pause menu.
    I want to create a pause menu, so I create it fully withing UI reading all https://bevyengine.org/examples/#ui-user-interface
    But what is UI exactly, is it just nodes that are show in a rather absolute fashion on the 2D screen? are they their own separate kind of components and answer to a UI specific logics? or they are encapsulated 2d meshes + material + transform that are just spawned in the UI which is a sort of implicit camera?

  2. I want to create a world to move entities in it, a simple 2d overworld.
    For now it's to me simple I can just spawn things into the world and just care when to load / unload things and how to layer stuff.
    Without thinking too much about what it is, I move the camera to show the world.

  3. in this world I want to interact with NPCs for example that shows me a selling UI, or open my inventory. Which can be considered an UI as everything needs to be in the viewport I must not move the camera for that, things must move for the camera.
    but my intuition tells me this is not an UI I want to do with bevyUI and rather a UI world I need to create with 2d meshes, sprites and etc.

  4. If I want to set a base resolution for my game, like a 640 * 360, how do I stretch it to fit bigger screen? and for smaller screen?
    there's this solution there: https://bevyengine.org/examples/window/window-resizing/
    but I was thinking about how godot explains it https://docs.godotengine.org/en/stable/tutorials/rendering/multiple_resolutions.html
    which explains all forms of fiting multiple resolutions.

Apologies if its difficult to follow as I probably miss use some terminology.

graceful iron
# earnest tide Hello, I have some trouble understanding how these concepts works together and h...
  1. UI is its own Components, which are fundamentally rendered differently than 2d or 3d. Theres layouting similar to CSS Flex, with which you position UI elements in the viewport of a camera.

  2. "the world" is a somewhat loaded term in bevy (and many ECS) as it can mean "the ecs world" aka the "database" which stores your entities, or the game world / coordinate space in which components like Transform act. If you spawn a sprite, it will be positioned with a Transform component in world coordinate space, which just happens to be 1 unit = 1 pixel for the default 2d camera. for 3d, the assumption is generally that 1 unit is more like 1 meter, but thats not something bevy defines. its just what some other crates like avian physics assume.

  3. The term which could help you here is "diegetic UI", UI which is rendered like sprites, meshes etc. and has a normal Transform. You can either not use this, or you could have a second camera which renders normal bevy UI to a texture, and put that texture in your world as a normal sprite or on a mesh or whatever.

  4. It sounds like you're talking about scaling modes. Bevy has a few of them: https://docs.rs/bevy/latest/bevy/render/camera/enum.ScalingMode.html - they define how the camera output is scaled when you change your window size.

#

i tried to just cover some parts of how i understood your questions and concerns, but ngl, it was a bit hard to understand what exactly you meant sometimes

earnest tide
#

Many thanks for your efforts

#

Gave me valuable insights

graceful iron
#

feel free to ask follow up questions, i'm sure i missed something you wanted to know