{"name":"animateSource","operator":null,"title":"animateSource","type":"command","url":"https://community.bistudio.com/wiki/animateSource","revid":353025,"updated":"2024-03-12T11:30:02Z","groups":["Animations"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"1.58"}],"since":{"game":"arma3","name":"Arma 3","version":"1.58"},"arma3_since":"1.58","branch":null,"locality":{"argument":"global","effect":"global","server_exec":false},"exec":null,"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).\n\n> [!NOTE]\n> **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\n\n> [!WARNING]\n> Mixing animateSource command with animate command to animate the same part may produce some undefined behaviour.","syntaxes":[{"syntax":"object animateSource [source, phase, speed]","since":null,"effect":null,"exec":null,"params":[{"name":"object","type":"Object","optional":false,"default":null,"description":null,"types":["Object"],"since":null,"text":"object: Object"},{"name":"source","type":"String","optional":false,"default":null,"description":"common source","types":["String"],"since":null,"text":"source: String - common source"},{"name":"phase","type":"Number","optional":false,"default":null,"description":"wanted animation phase","types":["Number"],"since":null,"text":"phase: Number - wanted animation phase"},{"name":"speed","type":"Boolean or Number","optional":true,"default":"false","description":"Boolean - when set to true, animation is instant\n- Arma 3 v1.66 Number > 0 is treated as config speed value multiplier. Since Arma 3 v2.10 values <= 0 will instantly reset animation to initPhase.","types":["Boolean","Number"],"since":null,"text":"speed: Boolean or Number - (Optional, default false)\n- Boolean - when set to true, animation is instant\n- Arma 3 v1.66 Number > 0 is treated as config speed value multiplier. Since Arma 3 v2.10 values <= 0 will instantly reset animation to initPhase."}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"binary","operator":null,"left":{"text":"object","types":["Object"]},"right":{"text":"[source, phase, speed]","types":["Array"]}}],"examples":[{"text":"```sqf\nhouse animateSource [\"Door_1_source\", 1, true];\n```","code":["house animateSource [\"Door_1_source\", 1, true];"]},{"text":"Create UGV and manipulate its turret (Not possible to do with animate command. See Arma 3: createVehicle/vehicles for reference)\n\n```sqf\nugv = \"B_UGV_01_F\" createVehicle (player getRelPos [5, 0]);\nugv addAction [\"Show Turret\",\n{\n    ugv animateSource [\"Turret\", 0];\n    ugv animateSource [\"MainTurret\", rad 0, true];\n    ugv animateSource [\"MainGun\", rad 0, true];\n}];\nugv addAction [\"Hide Turret\",    { ugv animateSource [\"Turret\", 1] }];\nugv addAction [\"Turret Left\",    { ugv animateSource [\"MainTurret\",     rad 90] }];\nugv addAction [\"Turret Right\",    { ugv animateSource [\"MainTurret\",    -rad 90] }];\nugv addAction [\"Turret Up\",        { ugv animateSource [\"MainGun\",         rad 30] }];\nugv addAction [\"Turret Down\",    { ugv animateSource [\"MainGun\",        -rad 20] }];\n```","code":["ugv = \"B_UGV_01_F\" createVehicle (player getRelPos [5, 0]);\nugv addAction [\"Show Turret\",\n{\n\tugv animateSource [\"Turret\", 0];\n\tugv animateSource [\"MainTurret\", rad 0, true];\n\tugv animateSource [\"MainGun\", rad 0, true];\n}];\nugv addAction [\"Hide Turret\",\t{ ugv animateSource [\"Turret\", 1] }];\nugv addAction [\"Turret Left\",\t{ ugv animateSource [\"MainTurret\",\t rad 90] }];\nugv addAction [\"Turret Right\",\t{ ugv animateSource [\"MainTurret\",\t-rad 90] }];\nugv addAction [\"Turret Up\",\t\t{ ugv animateSource [\"MainGun\",\t\t rad 30] }];\nugv addAction [\"Turret Down\",\t{ ugv animateSource [\"MainGun\",\t\t-rad 20] }];"]},{"text":"```sqf\nbarGate animateSource [\"Door_1_sound_source\", 1]; // Open\nbarGate animateSource [\"Door_1_sound_source\", 0]; // Close\n```","code":["barGate animateSource [\"Door_1_sound_source\", 1]; // Open\nbarGate animateSource [\"Door_1_sound_source\", 0]; // Close"]},{"text":"Open/close Bar Gate automatically:\n\n```sqf\n// Bar Gate init\nif (isServer) then\n{    \n    private _gateTrigger = createTrigger [\"EmptyDetector\", getPosWorld this, false];\n    _gateTrigger setVariable [\"BarGateObj\", this];\n    _gateTrigger setTriggerActivation [\"ANYPLAYER\", \"PRESENT\", true];\n    _gateTrigger setTriggerArea [5, 25, getDir this, true];\n    _gateTrigger setTriggerStatements \n    [\n        \"this\",\n        \"thisTrigger getVariable 'BarGateObj' animateSource ['Door_1_sound_source', 1]\",\n        \"thisTrigger getVariable 'BarGateObj' animateSource ['Door_1_sound_source', 0]\"\n    ];\n};\n```","code":["// Bar Gate init\nif (isServer) then\n{\t\n\tprivate _gateTrigger = createTrigger [\"EmptyDetector\", getPosWorld this, false];\n\t_gateTrigger setVariable [\"BarGateObj\", this];\n\t_gateTrigger setTriggerActivation [\"ANYPLAYER\", \"PRESENT\", true];\n\t_gateTrigger setTriggerArea [5, 25, getDir this, true];\n\t_gateTrigger setTriggerStatements \n\t[\n\t\t\"this\",\n\t\t\"thisTrigger getVariable 'BarGateObj' animateSource ['Door_1_sound_source', 1]\",\n\t\t\"thisTrigger getVariable 'BarGateObj' animateSource ['Door_1_sound_source', 0]\"\n\t];\n};"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["animationSourcePhase","setFaceAnimation","animate","animationPhase","animateDoor","doorPhase","animationNames"],"notes":[],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: Animations","Introduced with Arma 3 version 1.58","Scripting Commands","Scripting Commands: Global Effect"]}