{"name":"setVelocityTransformation","operator":null,"title":"setVelocityTransformation","type":"command","url":"https://community.bistudio.com/wiki/setVelocityTransformation","revid":377448,"updated":"2026-01-02T06:47:04Z","groups":["Object Manipulation"],"status":"ok","replaced_by":[],"games":[{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},"arma3_since":"0.50","branch":null,"locality":{"argument":"local","effect":"global","server_exec":false},"exec":null,"description":"Interpolates and applies PositionASL, velocity, vectorDir and vectorUp to the given object based on the interval value.\n\nWhen interval is 0 the \"fromXXX\" values are used for the beginning of the interpolation. When interval is 1, the \"toXXX\" values are used for the end of interpolation.\nWhen interval value is in between, interpolated values are used (see diagram below). The interpolation is linear and along straight line between \"from\" and \"to\" positions.\nIf curve is needed, then it should be constructed from multiple straight sections or by dynamically changing value of position params during the interpolation cycle, similar to [Quadratic Curve animation](https://en.wikipedia.org/wiki/B%C3%A9zier_curve#Quadratic_curves) (see #Example 3).\n\nThe velocity param does not do much in SP, but in MP, provided the velocity component is set correctly, it helps the engine to figure out what the next position of the moving object should be on other clients.\n\nThe actual approximate interpolation formula for this command is:\n\n```sqf\n_vecCurrent = _vecFrom vectorAdd (_vecTo vectorDiff _vecFrom vectorMultiply _interval);\n```\n\n> [!NOTE]\n> For continuous movement this command should be executed each frame while changing the interval value.\n> For example to apply interpolation for 10 seconds one could use the following command to translate 10 seconds into 0..1 interval:\n>\n> ```sqf\n> t1 = time;\n> t2 = time + 10;\n> ```\n>\n> Later inside some on frame event...\n>\n> ```sqf\n> _interval = linearConversion [t1, t2, time, 0, 1];\n> ```","syntaxes":[{"syntax":"object setVelocityTransformation [fromPosASL, toPosASL, fromVelocity, toVelocity, fromVectorDir, toVectorDir, fromVectorUp, toVectorUp, interval, customCenter]","since":null,"effect":null,"exec":null,"params":[{"name":"object","type":"Object","optional":false,"default":null,"description":"object to be interpolated","types":["Object"],"since":null,"text":"object: Object - object to be interpolated"},{"name":"fromPosASL","type":"PositionASL","optional":false,"default":null,"description":"starting getPosASL of the object","types":["PositionASL"],"since":null,"text":"fromPosASL: PositionASL - starting getPosASL of the object"},{"name":"toPosASL","type":"PositionASL","optional":false,"default":null,"description":"ending getPosASL of the object","types":["PositionASL"],"since":null,"text":"toPosASL: PositionASL - ending getPosASL of the object"},{"name":"fromVelocity","type":"Vector3D","optional":false,"default":null,"description":"starting velocity of the object","types":["Vector3D"],"since":null,"text":"fromVelocity: Vector3D - starting velocity of the object"},{"name":"toVelocity","type":"Vector3D","optional":false,"default":null,"description":"ending velocity of the object","types":["Vector3D"],"since":null,"text":"toVelocity: Vector3D - ending velocity of the object"},{"name":"fromVectorDir","type":"Vector3D","optional":false,"default":null,"description":"starting vectorDir of the object","types":["Vector3D"],"since":null,"text":"fromVectorDir: Vector3D - starting vectorDir of the object"},{"name":"toVectorDir","type":"Vector3D","optional":false,"default":null,"description":"ending vectorDir of the object","types":["Vector3D"],"since":null,"text":"toVectorDir: Vector3D - ending vectorDir of the object"},{"name":"fromVectorUp","type":"Vector3D","optional":false,"default":null,"description":"starting vectorUp of the object","types":["Vector3D"],"since":null,"text":"fromVectorUp: Vector3D - starting vectorUp of the object"},{"name":"toVectorUp","type":"Vector3D","optional":false,"default":null,"description":"ending vectorUp of the object","types":["Vector3D"],"since":null,"text":"toVectorUp: Vector3D - ending vectorUp of the object"},{"name":"interval","type":"Number","optional":false,"default":null,"description":"interpolation interval (variable value, normally between 0 and 1)","types":["Number"],"since":null,"text":"interval: Number - interpolation interval (variable value, normally between 0 and 1)"},{"name":"customCenter","type":"PositionRelative","optional":true,"default":"placing point of the model (see getModelInfo)","description":"custom center [x, y, z] to which transformation would be applied in model coordinates","types":["PositionRelative"],"since":"arma3 2.08","text":"customCenter: PositionRelative - (Optional, default placing point of the model (see getModelInfo)) custom center [x, y, z] to which transformation would be applied in model coordinates"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"binary","operator":null,"left":{"text":"object","types":["Object"]},"right":{"text":"[fromPosASL, toPosASL, fromVelocity, toVelocity, fromVectorDir, toVectorDir, fromVectorUp, toVectorUp, interval, customCenter]","types":["Array"]}}],"examples":[{"text":"```sqf\n_tracker setVelocityTransformation\n[\n    _currentPos,\n    _nextPos,\n    _currentVelocity,\n    _nextVelocity,\n    _currentVectorDir,\n    _nextVectorDir,\n    _currentVectorUp,\n    _nextVectorUp,\n    _interval\n];\n```","code":["_tracker setVelocityTransformation\n[\n\t_currentPos,\n\t_nextPos,\n\t_currentVelocity,\n\t_nextVelocity,\n\t_currentVectorDir,\n\t_nextVectorDir,\n\t_currentVectorUp,\n\t_nextVectorUp,\n\t_interval\n];"]},{"text":"Bob on imaginary stairway to heaven:\n\n```sqf\nbob = createAgent [\"C_man_1\", player getRelPos [5, 0], [], 0, \"CAN_COLLIDE\"];\nbob switchMove \"ladderCivilUpLoop\";\npos1 = getPosASL bob;\npos2 = pos1 vectorAdd [0,0,0.75];\nbob addEventHandler [\"AnimDone\",\n{\n    pos1 = pos2;\n    pos2 = pos2 vectorAdd [0,0,0.75]\n}];\n\nonEachFrame\n{\n    if (!alive bob) then\n    {\n        onEachFrame {};\n        bob switchMove \"\";\n        bob removeAllEventHandlers \"AnimDone\";\n    };\n    bob setVelocityTransformation [\n        pos1,\n        pos2,\n        [0,0,0],\n        [0,0,0],\n        [0,1,0],\n        [0,1,0],\n        [0,0,1],\n        [0,0,1],\n        moveTime bob\n    ];\n};\n```","code":["bob = createAgent [\"C_man_1\", player getRelPos [5, 0], [], 0, \"CAN_COLLIDE\"];\nbob switchMove \"ladderCivilUpLoop\";\npos1 = getPosASL bob;\npos2 = pos1 vectorAdd [0,0,0.75];\nbob addEventHandler [\"AnimDone\",\n{\n\tpos1 = pos2;\n\tpos2 = pos2 vectorAdd [0,0,0.75]\n}];\n\nonEachFrame\n{\n\tif (!alive bob) then\n\t{\n\t\tonEachFrame {};\n\t\tbob switchMove \"\";\n\t\tbob removeAllEventHandlers \"AnimDone\";\n\t};\n\tbob setVelocityTransformation [\n\t\tpos1,\n\t\tpos2,\n\t\t[0,0,0],\n\t\t[0,0,0],\n\t\t[0,1,0],\n\t\t[0,1,0],\n\t\t[0,0,1],\n\t\t[0,0,1],\n\t\tmoveTime bob\n\t];\n};"]},{"text":"Advanced trickery with curved movement. The curve is controlled with one control point (controlPointASL), just like quadratic Bézier curve:\n\n```sqf\ndisableSerialization;\nplayer setDir 0;\ninterval = 0;\n_disp = findDisplay 46 createDisplay \"RscDisplayEmpty\";\n_ctrl = _disp ctrlCreate [\"RscSlider\", -1];\n_ctrl ctrlSetPosition [safeZoneX + 0.1, 1, safeZoneW - 0.2, 0.1];\n_ctrl ctrlSetActiveColor [1,0,0,1];\n_ctrl ctrlCommit 0;\n_ctrl sliderSetPosition 0;\n_ctrl sliderSetRange [0,1];\n_ctrl sliderSetSpeed [0.1,0.5];\n_ctrl ctrlAddEventHandler [\"SliderPosChanged\", {interval = _this select 1}];\nctrlSetFocus _ctrl;\nbox = \"Land_VR_Shape_01_cube_1m_F\" createVehicle [0,0,0];\ncontrolPointASL = AGLToASL (player getRelPos [70, -30]) vectorAdd [0, 0, 30];\nfromPosASL = AGLToASL (player getRelPos [10, -45]);\ntoPosASL = AGLToASL (player getRelPos [10, 45]);\nfromControlPointOffset = controlPointASL vectorDiff fromPosASL;\ntoControlPointOffset = toPosASL vectorDiff controlPointASL;\nonEachFrame\n{\n    hintSilent format [\"Interval: %1\", interval];\n    box setVelocityTransformation\n    [\n        fromPosASL vectorAdd (fromControlPointOffset vectorMultiply interval),\n        controlPointASL vectorAdd (toControlPointOffset vectorMultiply interval),\n        [0,0,0],\n        [0,0,0],\n        [0,1,0],\n        [1,0,0],\n        [0,0,1],\n        [0,1,0],\n        interval\n    ];\n};\n```","code":["disableSerialization;\nplayer setDir 0;\ninterval = 0;\n_disp = findDisplay 46 createDisplay \"RscDisplayEmpty\";\n_ctrl = _disp ctrlCreate [\"RscSlider\", -1];\n_ctrl ctrlSetPosition [safeZoneX + 0.1, 1, safeZoneW - 0.2, 0.1];\n_ctrl ctrlSetActiveColor [1,0,0,1];\n_ctrl ctrlCommit 0;\n_ctrl sliderSetPosition 0;\n_ctrl sliderSetRange [0,1];\n_ctrl sliderSetSpeed [0.1,0.5];\n_ctrl ctrlAddEventHandler [\"SliderPosChanged\", {interval = _this select 1}];\nctrlSetFocus _ctrl;\nbox = \"Land_VR_Shape_01_cube_1m_F\" createVehicle [0,0,0];\ncontrolPointASL = AGLToASL (player getRelPos [70, -30]) vectorAdd [0, 0, 30];\nfromPosASL = AGLToASL (player getRelPos [10, -45]);\ntoPosASL = AGLToASL (player getRelPos [10, 45]);\nfromControlPointOffset = controlPointASL vectorDiff fromPosASL;\ntoControlPointOffset = toPosASL vectorDiff controlPointASL;\nonEachFrame\n{\n\thintSilent format [\"Interval: %1\", interval];\n\tbox setVelocityTransformation\n\t[\n\t\tfromPosASL vectorAdd (fromControlPointOffset vectorMultiply interval),\n\t\tcontrolPointASL vectorAdd (toControlPointOffset vectorMultiply interval),\n\t\t[0,0,0],\n\t\t[0,0,0],\n\t\t[0,1,0],\n\t\t[1,0,0],\n\t\t[0,0,1],\n\t\t[0,1,0],\n\t\tinterval\n\t];\n};"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["velocity","setVelocity","velocityModelSpace","setVelocityModelSpace","speed","moveTime","disableBrakes","brakesDisabled","getModelInfo"],"notes":[{"user":"ffur2007slx2_5","date":"2014-08-04T12:35:00Z","text":"(A3 1.24) Generally speaking setVelocityTransformation is more likely a combination of setPosASL, setVectorDirAndUp (or BIS_fnc_setPitchBank) and time multiplier.\nIt can be used as a position tracker with all necessary information collected, copied and then released within one function. Here’s a simple reproduction on how setVelocityTransformation works in game:\n\n```sqf\nprivate [\"_dataOld\",\"_dataNext\",\"_capturedData\",\"_obj\",\"_fps\",\"_startTrackingTime\",\"_stepOld\",\"_stepNext\",\"_tracker\",\"_tempTime\"];\n_stepOld = 0;\n_tempTime = 0;\n_stepNext = 1;\nwhile {true} do\n{\n    _capturedData = _capturedData + [[getPosASL _obj,velocity _obj,vectorDir _obj,vectorUp _obj]];\n    sleep _fps;\n    _tempTime = _tempTime + _fps;\n    if (_tempTime >= _startTrackingTime) then\n    {\n        _dataOld = _capturedData select _stepOld;\n        _dataNext = _capturedData select _stepNext;\n        _stepOld = _stepOld + 1;\n        _stepNext = if (_stepNext >= (count _capturedData)) then { _stepOld } else { _stepNext + 1 };\n        _tracker setVelocityTransformation [\n            _dataOld select 0,\n            _dataNext select 0,\n            _dataOld select 1,\n            _dataNext select 1,\n            _dataOld select 2,\n            _dataNext select 2,\n            _dataOld select 3,\n            _dataNext select 3,\n            1\n        ];\n    };\n};\n```\n\nTracker starts coping the route and stance from the object when time start counting. TimeDiff determines the distance multiply between the current position and the next position."},{"user":"DrSova","date":"2020-07-04T08:11:00Z","text":"You can't apply this command to the dead body in ragdoll."}],"categories":["Arma 2: Operation Arrowhead: New Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 3: Scripting Commands","Command Group: Object Manipulation","Introduced with Arma 2: Operation Arrowhead version 1.50","Scripting Commands","Scripting Commands: Global Effect","Take On Helicopters: Scripting Commands"]}