Call of Duty 5: Body Animation: Difference between revisions

From COD Modding & Mapping Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
[[Image:Nutshell.png]] Body animations in Call of Duty can be played by any AI.
{{Note|Body animations in Call of Duty can be played by any AI.}}


For a list of animations you can use visit the [[Call of Duty 5: List Of Animations|'''List of Animations''']] page.
For a list of animations you can use visit the [[Call of Duty 5: List Of Animations|'''List of Animations''']] page.
Line 71: Line 71:
That line will have your AI play a generic lip syncing animation while speaking where ever he is standing when that line is called.
That line will have your AI play a generic lip syncing animation while speaking where ever he is standing when that line is called.


==Animating At A Specific Location==
==Animating 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.
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.


[[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.
{{Warning|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)
Line 119: Line 119:
</pre>
</pre>


===Wait For Notfy===
===Wait for Notify===


Another way of simulating AI conversing would be to wait for a notify from the animation.
Another way of simulating AI conversing would be to wait for a notify from the animation.
Line 163: Line 163:
</pre>
</pre>


[[Category:Call of Duty 5]]
[[Category:Scripting]]
[[Category:Animations]]
[[Category:AI]]
[[Category:AI]]
[[Category:Call of Duty 5]]
[[Category:Modding]]
[[Category:Modding]]
[[Category:Animations]]
[[Category:Scripting]]

Latest revision as of 17:12, 29 July 2009

Body animations in Call of Duty can be played by any AI.

For a list of animations you can use visit the List of Animations page.

We will go over how to implement body animations and what you can do with animation system in regards to body animations and mixing it in with 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 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 "meet_by_wall"
  5. Our animation refers to an animation "Ch_oki3_regroup_sarge_order"

AI Animating

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, "meet_by_wall" );

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

Animating 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, "meet_by_wall" ); // Call the anim function on the variable that has our script_struct

Multiple AI Animating

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, "meet_by_wall" );
Non-Threading level.sarge anim_single_solo( level.sarge, "meet_by_wall" );

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, "meet_by_wall" ); // 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, "meet_by_wall" ); // 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, "meet_by_wall" ); // First dialog animation
   
   wait 3 ; // Wait 3 seconds
   
   level.polansky thread anim_single_solo( level.polansky, "whispers" ); // Second dialog animation
 }