Search Unity

Displaying AR (augmented reality) effects via VR (virtual reality)

Discussion in 'UGUI & TextMesh Pro' started by unwitty, Feb 9, 2015.

  1. unwitty

    unwitty

    Joined:
    Jan 18, 2015
    Posts:
    31
    I have a VR project that I'm working on that involves overlaying AR information over objects in the game world.

    The scenario is this: There are rocks flying your way, and the HUD displays information about the rocks as they zoom towards and then past you. Like this,


    What I've done to create this is to instantiate the rocks with random positions, and instantiating HUD panels (using quads) as children to the rocks. The panels are UI elements rendered in World Space, and are rendered over all other game objects (by creating a customized shader). The rocks rotate, and so do the HUD panels but that is alright.

    The problem with this is: When a rock is partially obstructed by a rock in front of it, the HUD panels of both rocks will overlap each other, making them difficult to read and hard to identify which panel belongs to which rock.

    How do I make it so that the HUD panels never overlap each other? And how do I create a line that connects the HUD panels to the center of a rock?
     
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
    The only way to test that scenario would be raycasting to ensure the UI elements do not overlap.
     
  3. unwitty

    unwitty

    Joined:
    Jan 18, 2015
    Posts:
    31
    Thanks for helping out. Do you mind expanding a bit on how to do raycasting for this purpose?
     
  4. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
    I knew you were going to say that :D
    Raycasting is a bit of a large subject, start here on the Unity3D Learn site http://unity3d.com/learn/tutorials/modules/beginner/physics/raycasting

    The basic premise is that you cast out from the camera in the area you want to draw the element, if it hits nothing, then just draw. if it hits something, work out how far you need to be to not overlap, update your position and then draw it.
     
  5. 3agle

    3agle

    Joined:
    Jul 9, 2012
    Posts:
    508
  6. unwitty

    unwitty

    Joined:
    Jan 18, 2015
    Posts:
    31
    Thanks for the help guys.