Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
Qix's avatar
Qix
Explorer
11 years ago

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

4 Replies

Replies have been turned off for this discussion
  • 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. :)
  • Anonymous's avatar
    Anonymous
    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.
  • 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++)
  • Thanks guys I very appreciate your help. :)