First of all, my apologies for making everyone wait so long for the second installment!Hopefully you have read the first edition of this tutorial, if not, you can read it here: http://www.developer.com/net/vb/article.php/1539561
In the last edition, we added the Microsoft Agent control to Visual Basic, and we created a program with Agent. This time well look at accessing animations, and multiple agents. The code in this tutorial will assume you have done everything in the first edition. Please note I that my references to “animation” could also be “method” or “command”.
All Agents come with standard animations, such as “load” or “hide”. If you create your own Agent, you can add custom animations. In the first tutorial, we used an animation in the line “Assistant.Show”. This is the animation for opening the character. For the Merlin character, the following animations exist:
* – These animations are looping animations. You must use the command “Assistant.Stop” before using another animation.
For space constraints, I have not listed descriptions of the animations. To see what they do, try them out. Only certain actions can be used in the form “Assistant.Show”. Most of the animations will need to be accessed like this:
You may have noticed that a lot of the animations have a return animation. This is provided to allow a smooth transition from one animation back to the neutral position (RestPose). Animations allow you to add life to your character, for example:
Assistant.ShowAssistant.Play "Wave"Assistant.Speak "Hello!"Assistant.Play "WaveReturn"
If you decide to create your own agent, it is a good idea to include most of these animations in your character. Only some of them are required by the Agent Character Editor (more to come in a later tutorial).
You can load more than one Agent at a time, allowing you to create drama, or anything else you can creatively think of! The easiest way to load another character, is to copy the code from the first tutorial, and change a few things:
Assistant -> Assistant2 (or similar)C:windowsmsagentcharsmerlin.acs -> c:windowsmsagentcharsanotheragent.acs
To see the second character, you will need to load it: Assistant2.Show. If you were to try creating a theater effect with the two agents now, you might be disappointed; the agents dont wait for one another! However, there is a way to script multiple agent speeches and actions. You must make use of Request and the Wait command. For example:
Assistant.Play "Greet"Set AssistantRequest = Assistant.Speak ("Hello!")Assistant2.Wait AssistantRequestAssistant2.Play "Announce"Set Assistant2Request = Assistant2.Speak ("Wazzup!")Assistant.Wait Assistant2RequestAssistant.Play "Pleased"Assistant.Speak "Now that is cool!"
To get the agents to look and sound the way you want will take some trial and error, but this should be a good starting point.
In The Next Tutorial
The next tutorial will focus on voice recognition and responding to user input. And I promise it won’t take so long =)