Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Converting Screen Space - Overlay to Screen Space - Camera

Discussion in 'Getting Started' started by Tenesty, May 5, 2022.

  1. Tenesty


    Mar 9, 2020
    I am having an issue with a UI element healthbar. I started making my UI under the screen space - overlay canvas render mode and everything was working fine but I've since changed to Screen Space - Camera as I find it better fits my game.

    After making this change my UI element under my canvas is now being offset to a strange position:
    The green health bar above is supposed to be right bellow my character as well as the red enemy you see on the screenshot. It works as intended its just not in the right position. Seems like its using my character as a 0,0 position and has a weird offset.

    This is the function that updates the position. It seems to be an issue with the 0,0 position of WorldToScreenPoint being the center of the screen. However I've tried many things and looked many places and cannot find a way to make the conversion. That function works perfectly if I switch back to Screen Space - Overlay.

    My Unity Editor window with my canvas settings

    I am trying to remove the offset from the position of the Healthbar on my Canvas. Any help is appreciated thank you.
    VionHD and Dark571 like this.