Arma 3
Not enough ratings
Unit Play/Unit Capture Functions
By Mouain Toppers
This guide focuses around (attempting to) using BIS's unit play and unit capture functions to get movement/weapons data from units to use inside missions.
These functions can be pretty useful for missions, but for the mission maker they can create headaches, as the capturing of data is literally done in a EXTREMELY inefficient way that will almost always end up with your game locking up for the duration of the capturing of data.

Anyhow, onto how to use this IF you can get it to work.
How to Use
How to use it is pretty simple, inside a unit's init box is usually effective enough to do the job.

2 - Duration (seconds)
3 - FPS
4- Record Firing Data
5- Delay before Starting

[VEHICLE, 50, 30, true, 10] spawn BIS_fnc_UnitCapture;

It seems for me anyways that if one of the five parameters was not filled in it would crash the game, so take that into mind.

After capturing is complete, the function will copy the data in a massive array of arrays to the clipboard.
How to Use the data in a Mission PROPERLY
If you want this to work properly, you'll need to compile the code this way to avoid issues.

VARIABLE = compile preprocessFile "name-of-script-with-data.sqf";

That will compile the large amount of data before it is used. (I would put it inside init.sqf since it will trigger before the mission itself starts, giving it time to load in). After its compiled you will call the code via the variable used to hold the data.

Calling the code to use it in the mission is simple.

[OBJECT, DATA-VARIABLE] spawn BIS_fnc_UnitPlay; will begin playing through the array of positions, and will freeze the vehicle once playback is done.

You'll also probably want to make sure that where the vehicle/object starts and stops is not within the players sight, as it will be stuck in place if its not playing data. The engine sounds will also still play even though the entire vehicle/object is frozen and nothing on it is moving.
< >
Blacksoldier 10 Mar 30, 2017 @ 8:23am 
If i would start a unit with Unitcapture not immediately at start mission but with a trigger what should i do? (sorry for bad english)
SIGILL Jul 27, 2014 @ 9:46am 
Alright, thanks a lot! This can indeed be useful in those situations I want a scripted sequence in my missions, since the sandbox-style AI does sometimes mess up such sequences.
Mouain Toppers  [author] Jul 27, 2014 @ 9:43am 
thats correct. It should mainly be used for AI units as once its done moving the selected object through the positions in the array it will freeze the vehicle where the positions end.

It's main purpose is for complex maneuvers with AI/something you want to happen every time you play through the mission exactly the same, since the AI is dynamic they might take a slightly different path each time you play through the mission. With this it will put the vehicle on rails so it will only go a certain way.

For example if i want a jet to bomb a convoy, the AI flying the jet might take a different approach to the convoy each time as it chooses its path to the target on the fly, so its a bit random. If i want that to happen all the time, exactly the same way and for the rounds to land in the same spot, then you'd use this function to make that happen.
SIGILL Jul 27, 2014 @ 9:32am 
It's not quite clear to me what this does. Does it record the unit's movement/actions so it can be played back, like a replay, in another mission? If so, does this work with units controlled by players?