openclonk/docs/sdk/script/fn/SetAnimationWeight.xml

59 lines
2.6 KiB
XML

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE funcs
SYSTEM '../../../clonk.dtd'>
<?xml-stylesheet type="text/xsl" href="../../../clonk.xsl"?>
<funcs>
<func>
<title>SetAnimationWeight</title>
<category>Animations</category>
<version>5.1 OC</version>
<syntax>
<rtype>bool</rtype>
<params>
<param>
<type>int</type>
<name>animation_number</name>
<desc>Animation number of the animation whose position to set.</desc>
</param>
<param>
<type>array</type>
<name>weight</name>
<desc>Specifies how to compute the weight of the animation in case the animation is combined with another animation in the given slot. The value needs to be created with one of the "Anim_" animation functions.</desc>
</param>
<param>
<type>int</type>
<name>attach_number</name>
<desc>If given, refers to the number of the attached mesh whose animation to change.</desc>
<optional />
</param>
</params>
</syntax>
<desc>Sets a new weight for the given animation. Returns <code>true</code> if the new AVP was set or <code>false</code> if there is no such animation with the given number or the refernced node is an animation node.</desc>
<remark>See the <emlink href="definition/animations.html">animation documentation</emlink> for further explanations of the animation system.</remark>
<examples>
<example>
<code>var angle = <funclink>Angle</funclink>(0, 0, <funclink>GetXDir</funclink>(), <funclink>GetYDir</funclink>());
<funclink>if</funclink>(angle &gt; 360) angle = 360 - angle;
<funclink>SetAnimationWeight</funclink>(swim_comb, <funclink>Anim_Const</funclink>(500+<funclink>Cos</funclink>(angle, 500)));</code>
<text>If swim_comb contains the number of an animation node combining a "swim up" and "swim down" animation (refer to the example of <funclink>PlayAnimation</funclink>), then this script sets the a weight depending on the cosine of the current swimming direction.</text>
</example>
</examples>
<related>
<funclink>PlayAnimation</funclink>
<funclink>GetAnimationPosition</funclink>
<funclink>SetAnimationPosition</funclink>
<funclink>GetAnimationWeight</funclink>
<funclink>Anim_Const</funclink>
<funclink>Anim_Linear</funclink>
<funclink>Anim_X</funclink>
<funclink>Anim_Y</funclink>
<funclink>Anim_AbsX</funclink>
<funclink>Anim_AbsY</funclink>
<funclink>Anim_XDir</funclink>
<funclink>Anim_YDir</funclink>
<funclink>Anim_Action</funclink>
</related>
</func>
<author>Clonk-Karl</author><date>2010-01</date>
</funcs>