Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

Position UI Element at game object position - Screen space Camera

Discussion in 'UGUI & TextMesh Pro' started by chris-oddbod-games, Mar 24, 2020.

  1. chris-oddbod-games

    chris-oddbod-games

    Joined:
    Mar 18, 2013
    Posts:
    7
    Hey guys,
    I position some overlay ui effects at the players position when the player dies etc. This worked fine when using a screen space overlay canvas, using

    Vector3 screenPt = cam.WorldToScreenPoint(playerPos)

    And positioning the ui element at this position.
    But we have switched over to using Screen space Camera so we can make use of post process on a ui camera BUT the ui elements are now offset off screen with the above code. Which makes sense.
    So I have the game camera, the ui camera and the canvas available in the code, so is there a way to correctly move the ui element to correct position?
    Many thanks
    Chris
     
  2. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    611
unityunity