Search Unity

Interaction with the environment

Discussion in '2D' started by mrgolemm, Jun 25, 2019.

  1. mrgolemm

    mrgolemm

    Joined:
    Jun 25, 2019
    Posts:
    16
    Hello! I create a game for android and I need help. There was a problem with the mechanics, which I do not know how to implement in technical terms. Interaction with the environment. When a character is suitable for a sufficient distance, he can click on an object that will create several buttons above him for interaction. If you step back or click on the item again, the buttons will disappear. My idea is shown in the pictures.



     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,448
    i'd try something like:
    when user clicks object, it checks distance to player, if close enough, show ui..
    then if user clicks again, hide ui,
    and if player is moving away, he has reference to last clicked object, and checks distance to it, to hide ui after too far.
    (actually might be better to have UI check for the distance to player, when its active)


    if UI is using unityUI, you can get screen position for the ui, based on that gameobject
    with something like http://answers.unity3d.com/questions/799616/unity-46-beta-19-how-to-convert-from-world-space-t.html

    or ui elements could be sprites also.