Call of Duty 5: Facial Animation: Difference between revisions

From COD Modding & Mapping Wiki
Jump to navigation Jump to search
 
Line 71: Line 71:


You can change where on the map an AI will play an animation by calling the animation function on the location rather than on the AI.
You can change where on the map an AI will play an animation by calling the animation function on the location rather than on the AI.
{{Note|The AI will not run to the location then play it, they will teleport to the location to play the animation if they aren't already at the location.}}
 
[[Image:warning.png]] The AI will not run to the location then play it, they will teleport to the location to play the animation if they aren't already at the location.


  anim_node = getStruct( "location_for_animation", "targetname" ); // Get the script_struct (location for animation)
  anim_node = getStruct( "location_for_animation", "targetname" ); // Get the script_struct (location for animation)

Latest revision as of 15:29, 10 November 2008

There are no facial animations in the sense that every voice over has its own custom animation, that would be thousands of animations required, most of them going unnoticed by players. Though that isn't to say there aren't facial animations, if an AI animation is right up in front of your screen speaking chances are they have a unique facial animation for the voice over. Otherwise, there is a dynamic facial lip syncing system in place that only requires you to pass through a sound.

We will go over how to implement facial animations and what you can do with animation system in regards to dialog.

Set Up

For basic instructions on how to set up your animation (AI and GSC script), visit the Animation Overview page.

In a nut shell, you will need to assign your AI an animName in script and have your sound alias animation set up.

For the remainder of this page, we will assume:

  1. You've included maps\_anim at the top of your GSC
  2. Our AI is stored in a variable level.sarge
  3. Our AI has an animName of "sarge"
  4. Our animation reference name is "nearly_there"
  5. Our animation refers to a sound alias "Oki3_IGD_238A_ROEB"

AI Speaking

anim_single_solo is the script call we will be using for our animation. The naming convention of the function is specifically why we chose it:

Name Meaning
anim Animation.
single Animation plays only once.
solo Animation played by one single AI.


The function parameters for anim_single_solo are (in respective order):

Parameter Mandatory Description
<guy> Yes Guy that animates.
<anime> Yes Animation scene.
<tag> No A tag to animate relative to.
<entity> No Overwrite the scene base.
<tag_entity> No Overwrite the base for the tag.


At the very minimum we will need to pass a guy and animation through to the function:

level.sarge thread anim_single_solo( level.sarge, "nearly_there" );

That line will have your AI play a generic lip syncing animation while speaking where ever he is standing when that line is called.

Speaking At A Specific Location

You can change where on the map an AI will play an animation by calling the animation function on the location rather than on the AI.

The AI will not run to the location then play it, they will teleport to the location to play the animation if they aren't already at the location.

anim_node = getStruct( "location_for_animation", "targetname" ); // Get the script_struct (location for animation)
anim_node thread anim_single_solo( level.sarge, "nearly_there" ); // Call the anim function on the variable that has our script_struct

AI Conversing

There are a couple ways you can go about accomplishing this, we will cover a few methods.

For our second AI we will assume:

  1. Our second AI is stored in a variable level.polansky
  2. Our second AI has an animName of "polansky"
  3. Our second animation reference name is "shadows"
  4. Our second animation refers to a sound alias "Oki3_IGD_242A_POLO"

Non-Threading

The simplest of the methods is to not thread our animation. Threading our functions stems to the called function but the parent function that made the call continues to keep progressing.

Threading level.sarge thread anim_single_solo( level.sarge, "nearly_there" );
Non-Threading level.sarge anim_single_solo( level.sarge, "nearly_there" );

With that, we can now make two converse:

 #include maps\_anim;
 #include maps\_utility;
 #include common_scripts\utility;

 main()
 {
   maps\_load::main();

   level.sarge anim_single_solo( level.sarge, "nearly_there" ); // First dialog animation
   level.polansky anim_single_solo( level.polansky, "whispers" ); // Second dialog animation
 }

Wait For Notify

Another way of simulating AI conversing would be to wait for a notify from the animation.

Every time we play an animation that isn't looping, there is a notification sent out when it is done playing. The notification is "single anim".

 #include maps\_anim;
 #include maps\_utility;
 #include common_scripts\utility;

 main()
 {
   maps\_load::main();

   level.sarge thread anim_single_solo( level.sarge, "nearly_there" ); // First dialog animation
   
   level.sarge waittillend( "single anim" ); // Waittill level.sarge finishes his animation
   
   level.polansky thread anim_single_solo( level.polansky, "whispers" ); // Second dialog animation
 }

Wait Time

Another way of simulating AI conversing would be to wait a defined amount of seconds between each animation.

 #include maps\_anim;
 #include maps\_utility;
 #include common_scripts\utility;

 main()
 {
   maps\_load::main();

   level.sarge thread anim_single_solo( level.sarge, "nearly_there" ); // First dialog animation
   
   wait 3 ; // Wait 3 seconds
   
   level.polansky thread anim_single_solo( level.polansky, "whispers" ); // Second dialog animation
 }


Sources: Treyarch's wiki