Microsoft & .NETVisual BasicBeginning MS Agent: Part 2

Beginning MS Agent: Part 2

Developer.com content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

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:

Acknowledge
Alert
AlertReturn
Announce
AnnounceReturn
Blink
Confused
ConfusedReturn
Congratulate
CongratulateReturn
Congratulate_2
Decline
DeclineReturn
DoMagic1
DoMagic2
DoMagicReturn
DontRecognize
DontRecognizeReturn
Explain
ExplainReturn
GestureDown
GestureDownReturn
GestureLeft
GestureLeftReturn
GestureRight
GestureRightReturn
GestureUp
GestureUpReturn
GetAttention
GetAttentionReturn
GlanceDown
GlanceLeft
GlanceRight
GlanceUp
Greet
GreetReturn
Hear_1
Hear_2
Hear_3
Hear_4
Hide
Idle1_1
Idle1_2
Idle1_3
Idle1_4
Idle2_1
Idle2_2
Idle3_1
Idle3_1Return
Idle3_2
LookDown
LookDownBlink
LookDownReturn
LookLeft
LookLeftBlink
LookLeftReturn
LookRight
LookRightBlink
LookRightReturn
LookUp
LookUpBlink
LookUpReturn
MoveDown
MoveDownReturn
MoveLeft
MoveLeftReturn
MoveRight
MoveRightReturn
MoveUp
MoveUpReturn
Pleased
PleasedReturn
Processing*
ProcessingReturn
Read
ReadContinued
ReadReturn
Reading*
ReadingReturn
RestPose
Sad
SadReturn
Searching*
SearchingReturn
Show
StartListening
StartListeningReturn
StopListening
StopListeningReturn
Suggest
SuggestReturn
Surprised
SurprisedReturn
Think
ThinkReturn
Uncertain
UncertainReturn
Wave
WaveReturn
Write
WriteContinued
WriteReturn
Writing*
WritingReturn

* – 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:

Assistant.Play "Animation" 

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 =)

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Latest Posts

Related Stories