Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Animation Reset Based on AirTap

Discussion in 'VR' started by AdvancedConcepts, Sep 15, 2016.

  1. AdvancedConcepts

    AdvancedConcepts

    Joined:
    Sep 15, 2016
    Posts:
    1
    I have a simple animation with 2 States. Idle & Rotate.
    Right now when I view the scene in the Hololens I select the object and it begins to rotate and finishes.
    I would like to be able to click on the object again to have it reset and begin rotating. I do not want it to loop as I would like to walk around the object then reset it back.
    As bonus I would like to be able to pause the rotation then continue.

    I have looked at plenty of tutorials and examples but nothing seemed to be around the select gesture based on an animation.

    I have been able to get this to work only by using a keyboard.such as this:


    If someone could respond with some example code on how to make this work that would be great.
     
  2. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
    You are not far from what you want to with the code you have above. The GestureRecognizer examples and explanation are in the Scripting reference which can be opened from your editor.

    You need to create a GestureRecognizer just like you did with your animator member.
    After that you need to setup the tapped event and the call to the event.
    Add a check inside of the OnTap call to check if you have hit the object using headRay. Check for the collider of the object.
    Then inside of the event you can put animator.SetBool call on a tap.

    GestureRecognizer
    class in UnityEngine.VR.WSA.Input

    Hope this helps.
     
  3. MrMatthias

    MrMatthias

    Joined:
    Sep 18, 2012
    Posts:
    191