PlayAnimation

Kategorie: Animationen
Ab Engineversion: 1.0 OC

Beschreibung

Spielt eine neue neue Animation ab. Der Rückgabewert der Funktion ist die Animationsnummer des eingefügten Animationsknotens, mit der die Animation später manipuliert oder wieder entfernt werden kann. Falls im angegebenen Slot bereits Animationen vorhanden sind, so wird auch ein Kombinationsknoten erstellt. Dieser erhält die zurückgegebene Nummer plus 1.

Syntax

int PlayAnimation(string animation, int slot, array position, array weight, int sibling, int attach_number);

Parameter

animation:
Name der abzuspielenden Animation.
slot:
Slot im Animation Stack in den die Animation eingefügt werden soll. Siehe Animationen.
position:
Bestimmt, wie die aktuelle Position der Animation berechnet wird. Diese wird mittels Animationsfunktionen der Form "Anim_" angegeben.
weight:
[opt] 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.
If nil, the animation is created with constant weight 1000 and other animations in the same slot are removed.
sibling:
[opt] Falls die Animation mit einer anderen Animation kombiniert wird, dann gibt dies den Knoten an, mit dem die neue Animation kombiniert wird. Falls nicht angegeben oder nil wird die Animation mit der obersten Animation des Slots verknüpft wie sie von GetRootAnimation zurückgeliefert wird.
attach_number:
[opt] If given, refers to the number of the attached mesh on which the animation is to be played.

Anmerkungen

If a weight is specified, other animations remain in the slot and are automatically combined. Scripters are responsible for removing animations either by replacing them (pass nil as weight), calling StopAnimation or using the ANIM_Remove flag in the Anim_Linear function.
Siehe die Animations-Dokumentation für eine Beschreibung des Animationssystems.

Beispiele

PlayAnimation("Scale", 5, Anim_Y(0, GetAnimationLength("Scale"), 0, 15), Anim_Const(1000));
Spielt die Animation "Scale" ab und überschreibt dabei eventuell bereits existierende Animationen in Slot 5 ohne sie zu entfernen. Die Animationsposition wird nach der Y-Position des Objekts gewählt, so dass die Animation mit der Fortbewegung des Clonks während des Kletterns synchronisiert ist.
var swim_up = PlayAnimation("SwimDiveUp", 5, Anim_Linear(0, 0, GetAnimationLength("SwimDiveUp"), 40, ANIM_Loop), Anim_Linear(0, 0, 1000, 15, ANIM_Remove));
var swim_down = PlayAnimation("SwimDiveDown", 5, Anim_Linear(0, 0, GetAnimationLength("SwimDiveDown"), 40, ANIM_Loop), Anim_Const(500), swim_up);
var swim_comb = swim_down + 1;
Überlagert eine SwimDiveUp- mit einer SwimDiveDown-Animation so, dass beide Animationen gleich viel Gewicht haben. Das Ergebnis ist, dass der Clonk waagerecht im Wasser liegt. Falls zuvor eine andere Animation in Slot 5 abgespielt wurde, so wird ein 15 Frames dauernder Übergang gemacht an dessen Ende die vorherige Animation entfernt wird. Mithilfe der Variablen swim_comb kann das Gewicht zwischen den beiden Animationen in weiteren Code der Schwimmrichtung angepasst werden.
Siehe auch: Anim_AbsX, Anim_AbsY, Anim_Action, Anim_Const, Anim_Linear, Anim_X, Anim_XDir, Anim_Y, Anim_YDir, GetAnimationList, SetAnimationPosition, SetAnimationWeight, StopAnimation, TransformBone
Clonk-Karl, 2010-01