Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.

How to start and stop an animation with the KeywordManager HTK

Hey guys,

i want to implement a voice command that controls the animation with the KeywordManager.

Does anybody worked with that and can help me how to handle that.

Thank you for your attention

I appreciate any help

Tagged:

Answers

  • JannikLassahnJannikLassahn ✭✭
    edited March 2017

    Basically, you have two options: Animation and Animator.
    While the Animation component is considered a legacy component, it is still useful for simple animations, like scaling or positioning objects.
    The Animator component is part of Unitys new and incredibly powerful animation system (also referred to as Mecanim). It handles the state of multiple animations and transitions between those animations for you. Although you have to get familiar with this system, I would recommend to use it.

    To use Animation, add the Animation component to your GameObject, select the animation to play and disable Play automatically. Also create and add a script that gets an instance of the Animation. This script must have a public method that calls the Play method of the Animation instance. You have to select this script and the mentioned method in the KeywordManager.

    To use Animator, create an AnimationController and set all animations and transitions in the Animation view. Create a trigger to start the animation. Select the Animator component and its function SetTrigger with the name of the trigger as parameter in the KeywordManager. A comprehensive tutorial can be found here.

    For more information about animation in Unity, please have a look at the offical tutorials and the documentation.

  • I just finished a post today for easy voice command wire ups. From here, do what folks are saying and just set triggers as needed in the keyword manager events.

  • @BillMcCrary,
    Thanks for your post in your blog. I checked it and it worked. The point is now, i made an animation with my 3d model and i want to control it with voice commands. So do i have to make a script which is controlls the animation and then add it to keyword manager? If so, what is the code for that, do you know that.

    @JannikLassahn,

    thank you for your response. I watched the tutorial in the link you sent me and its pretty nice, but the animation there is controlled by a collider as a trigger. I would like to controll an animation via voice commands. ( Look at the text above). Do i have to make a script which controlls the animation and add the object with its script/function into the keyword manager??? What is the code for controlling an animation then?

    Thank you guys for your attention, its very important for me and my project.

  • I am not sure this is too late. But may be useful for the future.
    Create a Boolean parameter and set that as the transition condition at the first animation state in Unity.

    public void OnSpeechKeywordRecognized(SpeechKeywordRecognizedEventData eventData)
    {
    switch (eventData.RecognizedText.ToLower())
    {
    case "start animation":
    anim.SetBool("AnimationStatus", true);
    break;
    case "stop animation":
    anim.SetBool("AnimationStatus", false);
    break;
    }
    }

  • @Karthik,

    thanks for your answer :D,
    but is that a javascrip or c#-script???

Sign In or Register to comment.