Search Unity

Does an object have a on Gaze method

Discussion in 'VR' started by Almypal, Jul 19, 2017.

  1. Almypal

    Almypal

    Joined:
    Jun 29, 2017
    Posts:
    20
    Hello All,

    Do 3D objects come with a method that is triggered when your currently looking at the object?

    Thank you
     
  2. JasonCostanza

    JasonCostanza

    Unity Technologies

    Joined:
    May 23, 2017
    Posts:
    404
    Mixed Reality Academy from Microsoft is a pretty good place for some basic tutorials on the topic, one of which includes gaze scripting. I ran through them myself and found them quite helpful. You can find those here: https://developer.microsoft.com/en-us/windows/mixed-reality/academy

    Note, we (Unity) don't directly support those tutorials so your mileage may vary if scripting has changed since they were posted. Hope that helps!
     
  3. Almypal

    Almypal

    Joined:
    Jun 29, 2017
    Posts:
    20
    Thank you
     
  4. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
    Just adding some more info

    Most object come with a collision detection via the mesh that is created with the object, best way to see this is creating a primitive object. You can use physics ray cast to see if you are colliding with an object, then have a function on the object that will detect when a collision happens.

    Here are some links to help on the API side:
    https://docs.unity3d.com/ScriptReference/Collider.OnCollisionEnter.html
    https://docs.unity3d.com/ScriptReference/Physics.Raycast.html