Animate an object based on voice command

Hello,

I have created a basic animation on a gameobject like changing its position, However I’m not able to integrate the animation(.anim file) to a code in C#, such that if I say “move”(voice command) , the animation should start, I’m a newbie to the animation and scripting in Unity, Please help me on how to integrate animation to scripting.
Thanks in advance

Do you have speech detection working?

there’s plugins for that if needed:

After that it should be easy…
if command was “move…” then play anim with this name Unity - Scripting API: Animator.Play

1 Like

Thanks for the swift reply could you please share a code snippet?

you could probably even make it play that animation directly by word command that was said,

GetComponent<Animator>().Play(command);

*command is the string you get from speech to text plugins…

(if it gives error, first need to test/check if that anim exists before trying to play…)