Skip to main content
Up and Coming
April 2, 2014

How to select object by looking at it?

Hi guys,

Not sure if this has been asked before. How do I select an object just by looking at it. Something like Proton pulses menu system.

Thanks
    This topic has been closed for replies.

    4 replies

    Participant
    April 2, 2014
    I'm new to all of this but I would imagine you would need to make a game object that its opacity is 0% and extends from your player's camera view so when it collides with certain objects it can trigger any behavior. I'm learning about Unity and would like to know an answer to your question as well. :)
    April 2, 2014
    Without going into implementation details, i would think if 'casting a ray' from the center of the camera outward to a certain extent. I am pretty sure this is used in unity for some example as well.
    Should be enough information available on that.
    Participant
    April 2, 2014
    You project a ray from the centre of the view outwards in the direction that you're looking and test to see what objects it collides with.

    The terms you're probably looking for are ray projection, ray-sphere collision, ray-mesh collision.

    You can do other things like just taking the dot product of the angle between the view direction, and the direction towards each UI element. When you find that smallest dot product, that's the object you select.

    Try stuff out and see how it feels, what bugs you find etc, the dot-product test is the quickest and easiest to do (depending on what you're working in - Unity/C++)
    QixAuthor
    Up and Coming
    April 2, 2014
    Thanks guys I very appreciate your help. :)