animateSource: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Created page with "{{Command|= Comments ____________________________________________________________________________________________ | arma3 |= Game name |0.50|= Game version |eff= global|=...")
 
m (Some wiki formatting)
 
(67 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma3 |= Game name
|game1= arma3
|version1= 1.58


|0.50|= Game version
|eff= global
|arg= global


|gr1= Animations


|eff= global|= Effects in MP
|descr= Process an animation of the object. If [[animate]] uses class name from [[CfgModels]] ''Animations'', [[animateSource]] uses name defined by the ''source'' property. AnimationSources can animate multiple [[animate]] Animations. AnimationSource is defined in [[:Category:CfgVehicles|CfgVehicles]]' [[Model Config#AnimationSources|AnimationSources]] (see [[Arma 3: createVehicle/vehicles]]).
|arg= global|= Arguments in MP
____________________________________________________________________________________________


| Activates object animations by source. If [[animate]] uses class name from [[CfgModels]] ''Animations'', [[animateSource]] uses name defined by ''source'' property. This allows to use the command simultaneously on a bunch of animations related to the same source.
{{Feature|arma3| It is recommended that [[animateSource]] command is used instead of [[animate]] whenever is possible, as it is more efficient and optimized for MP}}
<br><br>
{{Feature|warning|Mixing [[animateSource]] command with [[animate]] command to animate the same part may produce some undefined behaviour.}}
A class with the same source name should also be present in main config in [[CfgVehicles]] ''AnimationSources'' and have to be bound to the "user" controller for the command to work. If in order to animate door in example below using [[animate]] command it would require 2 calls:
<br><br>
<tt>house [[animate]] ["Door_1_rot", 1];</tt>
<br>
<tt>house [[animate]] ["Door_Handle_1_rot_1", 1];</tt>
<br><br>
With [[animateSource]] this would require only 1 (provided everything is configured correctly):
<br><br>
<tt>house [[animateSource]] ["Door_1_source", 1];</tt>
<br><br>
<syntaxhighlight lang="cpp">
// model.cfg
....
class Animations
{
class Door_1_rot
{
type = rotation;
source = Door_1_source;
selection = Door_1;
axis = Door_1_axis;
memory = 1;
minValue = 0.1;
maxValue = 1;
angle0 = 0;
angle1 = (rad 110);
};
class Door_Handle_1_rot_1: Door_1_rot
{
source = Door_1_source;
selection = Door_Handle_1;
axis = Door_Handle_1_axis;
minValue = 0;
maxValue = 0.1;
angle0 = 0;
angle1 = (rad -50);
};
};
...


// config.cpp
|s1= object [[animateSource]] [source, phase, speed]
...
class AnimationSources
{
class Door_1_source
{
source = "user";
animPeriod = 2;
initPhase = 0;
};
};
...</syntaxhighlight>
Wanted animation phase is set with phase param.  To animate doors or other sources that have "user" controller, use [[animate]] command, or even better, [[animateSource]] (recommended). Sources with "hit" controller can be animated with [[setHitPointDamage]] command applied to the name contained in hitpoint property. For availability of animation sources and their controller types see: [[createVehicle/vehicles]]|= Description
____________________________________________________________________________________________


| object '''animateSource''' [source, phase, now] |= Syntax
|p1= object: [[Object]]


|p1= object: [[Object]] |= PARAMETER1
|p2= source: [[String]] - common source


|p2= [source, phase, now]: [[Array]] |= PARAMETER2
|p3= phase: [[Number]] - wanted animation phase


|p3= source: [[String]] |= PARAMETER3
|p5= speed: [[Boolean]] or [[Number]] - (Optional, default [[false]])
* [[Boolean]] - when set to [[true]], animation is instant
* {{GVI|arma3|1.66|size= 0.75}} [[Number]] > 0 is treated as config speed value multiplier. Since {{GVI|arma3|2.10|size= 0.75}} values <= 0 will instantly reset animation to initPhase.


|p4= phase: [[Number]] |= PARAMETER4
|r1= [[Nothing]]


|p5= now: [[Boolean]]  |= PARAMETER5
|x1= <sqf>house animateSource ["Door_1_source", 1, true];</sqf>


| [[Nothing]] |= RETURNVALUE
|x2= Create UGV and manipulate its turret (Not possible to do with [[animate]] command. See [[Arma 3: createVehicle/vehicles]] for reference)
<sqf>
ugv = "B_UGV_01_F" createVehicle (player getRelPos [5, 0]);
ugv addAction ["Show Turret",
{
ugv animateSource ["Turret", 0];
ugv animateSource ["MainTurret", rad 0, true];
ugv animateSource ["MainGun", rad 0, true];
}];
ugv addAction ["Hide Turret", { ugv animateSource ["Turret", 1] }];
ugv addAction ["Turret Left", { ugv animateSource ["MainTurret", rad 90] }];
ugv addAction ["Turret Right", { ugv animateSource ["MainTurret", -rad 90] }];
ugv addAction ["Turret Up", { ugv animateSource ["MainGun", rad 30] }];
ugv addAction ["Turret Down", { ugv animateSource ["MainGun", -rad 20] }];
</sqf>


|x3= <sqf>
barGate animateSource ["Door_1_sound_source", 1]; // Open
barGate animateSource ["Door_1_sound_source", 0]; // Close
</sqf>


|x1= <code>house [[animateSource]] ["Door_1_source", 1];</code>|= EXAMPLE1
|x4= Open/close Bar Gate automatically:
|x2= Open left front door on Ifrit instantly:<code>ifrit [[animateDoor]] ["Door_LF", 1, [[true]]];</code>|= EXAMPLE2
<sqf>
// Bar Gate init
if (isServer) then
{
private _gateTrigger = createTrigger ["EmptyDetector", getPosWorld this, false];
_gateTrigger setVariable ["BarGateObj", this];
_gateTrigger setTriggerActivation ["ANYPLAYER", "PRESENT", true];
_gateTrigger setTriggerArea [5, 25, getDir this, true];
_gateTrigger setTriggerStatements
[
"this",
"thisTrigger getVariable 'BarGateObj' animateSource ['Door_1_sound_source', 1]",
"thisTrigger getVariable 'BarGateObj' animateSource ['Door_1_sound_source', 0]"
];
};
</sqf>


____________________________________________________________________________________________
|seealso= [[animationSourcePhase]] [[setFaceAnimation]] [[animate]] [[animationPhase]] [[animateDoor]] [[doorPhase]] [[animationNames]]
 
| [[doorPhase]], [[animate]], [[animationPhase]], [[setFaceAnimation]] |= SEEALSO
 
|  |= MPBEHAVIOUR
____________________________________________________________________________________________
}}
}}
<h3 style='display:none'>Notes</h3>
<dl class='command_description'>
<!-- Note Section BEGIN -->
<!-- Note Section END -->
</dl>
<h3 style='display:none'>Bottom Section</h3>
[[Category:Arma_3:_New_Scripting_Commands_List|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]

Latest revision as of 13:30, 12 March 2024

Hover & click on the images for description

Description

Description:
Process an animation of the object. If animate uses class name from CfgModels Animations, animateSource uses name defined by the source property. AnimationSources can animate multiple animate Animations. AnimationSource is defined in CfgVehicles' AnimationSources (see Arma 3: createVehicle/vehicles).
Arma 3
It is recommended that animateSource command is used instead of animate whenever is possible, as it is more efficient and optimized for MP
Mixing animateSource command with animate command to animate the same part may produce some undefined behaviour.
Groups:
Animations

Syntax

Syntax:
object animateSource [source, phase, speed]
Parameters:
object: Object
source: String - common source
phase: Number - wanted animation phase
speed: Boolean or Number - (Optional, default false)
  • Boolean - when set to true, animation is instant
  • Arma 3 logo black.png1.66 Number > 0 is treated as config speed value multiplier. Since Arma 3 logo black.png2.10 values <= 0 will instantly reset animation to initPhase.
Return Value:
Nothing

Examples

Example 1:
house animateSource ["Door_1_source", 1, true];
Example 2:
Create UGV and manipulate its turret (Not possible to do with animate command. See Arma 3: createVehicle/vehicles for reference)
ugv = "B_UGV_01_F" createVehicle (player getRelPos [5, 0]); ugv addAction ["Show Turret", { ugv animateSource ["Turret", 0]; ugv animateSource ["MainTurret", rad 0, true]; ugv animateSource ["MainGun", rad 0, true]; }]; ugv addAction ["Hide Turret", { ugv animateSource ["Turret", 1] }]; ugv addAction ["Turret Left", { ugv animateSource ["MainTurret", rad 90] }]; ugv addAction ["Turret Right", { ugv animateSource ["MainTurret", -rad 90] }]; ugv addAction ["Turret Up", { ugv animateSource ["MainGun", rad 30] }]; ugv addAction ["Turret Down", { ugv animateSource ["MainGun", -rad 20] }];
Example 3:
barGate animateSource ["Door_1_sound_source", 1]; // Open barGate animateSource ["Door_1_sound_source", 0]; // Close
Example 4:
Open/close Bar Gate automatically:
// Bar Gate init if (isServer) then { private _gateTrigger = createTrigger ["EmptyDetector", getPosWorld this, false]; _gateTrigger setVariable ["BarGateObj", this]; _gateTrigger setTriggerActivation ["ANYPLAYER", "PRESENT", true]; _gateTrigger setTriggerArea [5, 25, getDir this, true]; _gateTrigger setTriggerStatements [ "this", "thisTrigger getVariable 'BarGateObj' animateSource ['Door_1_sound_source', 1]", "thisTrigger getVariable 'BarGateObj' animateSource ['Door_1_sound_source', 0]" ]; };

Additional Information

See also:
animationSourcePhase setFaceAnimation animate animationPhase animateDoor doorPhase animationNames

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note