Jump to content
Sign in to follow this  
Big Dawg KS

[OA] UnitCapture & UnitPlay Functions

Recommended Posts

So I was going through BIS's scripts and stuff and came across something very interesting, and so I thought I'd see if it interests you guys.

Operation Arrowhead includes a new set of of functions called UnitCapture & UnitPlay. From what I've gathered, they basically allow you to capture the movement data (and there's one for weapon firing data) of a unit, and then play it back exactly the same way every time.

It's how BIS pulled off those seemingly impossible (for AI at least) littlebird insertions in the campaign. In short, all you have to do is call CaptureUnit on a vehicle (it appears to work on people to), drive/fly it around as you see fit, and it will copy the movement data to the clipboard. Then, simply paste the data in a script, call the PlayUnit function with this data and it will play back the same movement you just recorded.

I imagine this can be used to some pretty substantial potential. Ex: getting AI to land aircraft on buildings/carriers, flying/driving through objects no AI could possibly pull off, and creating some very complex cinematic scenes. Now I haven't got a chance to actually try it yet, but judging from it's use in the campaign it seems to work very nicely (at least on aircraft).

You can find some documentation in the scripts themselves. They're in the OA modules pbo, under 'scenes'. Hope this interests some of you mission (and movie) makers.

Edited by Big Dawg KS

Share this post


Link to post
Share on other sites

HOLY SHIT! So when you have problems getting the AI to do as you want, just record it yourself and let them play it instead. That's just brilliant!! Prequel to AAR? :p

Share this post


Link to post
Share on other sites

Can you give some a more detailed location for a noob on where the documentation is and how to access it?

Share this post


Link to post
Share on other sites

If this works it could be worth starting a 'MoveData Scripts' sticky thread here. Ppl could post all kinds of recorded movements that make sense for mission designers like searching patterns, getting in /out of houses with leaning etc etc.

This could be good. :)

Share this post


Link to post
Share on other sites

Keep in mind this script is designed for air units, like helicopters and aircrafts. It's not working properly with ground units (wheels are not turning with vehicle among other things) and it doesn't capture soldier's animations.

Also, using too many recorded paths can lead to slower framerate. Use as you wish for making videos, but be really careful when using it in playable mission.

Share this post


Link to post
Share on other sites

Could this also be used for normally static objects? Like say getting an empty vehicle to move around in a certain pattern? I am thinking of moving targets on a tank gunnery range, lack of animation isn't a problem.

Share this post


Link to post
Share on other sites
Keep in mind this script is designed for air units, like helicopters and aircrafts. It's not working properly with ground units (wheels are not turning with vehicle among other things) and it doesn't capture soldier's animations.

Also, using too many recorded paths can lead to slower framerate. Use as you wish for making videos, but be really careful when using it in playable mission.

Right, I was kind of expecting that since the functions and captured data didn't seem to contain anything about animation states/phases. Maybe in the future though. :cool:

Could this also be used for normally static objects? Like say getting an empty vehicle to move around in a certain pattern? I am thinking of moving targets on a tank gunnery range, lack of animation isn't a problem.

Trracer, I would imagine so. It should work on anything that can be given a velocity. Static objects might not work though.

---------- Post added at 08:26 AM ---------- Previous post was at 06:57 AM ----------

)rStrangelove;1665575']If this works it could be worth starting a 'MoveData Scripts' sticky thread here. Ppl could post all kinds of recorded movements that make sense for mission designers like searching patterns' date=' getting in /out of houses with leaning etc etc.

This could be good. :)[/quote']

I was also thinking of something like this where users (who are perhaps very skilled pilots) can share their captured moves. When I get home tonight I'll probably fiddle around with the capture function and see if I can pull off some cool things with it.

Share this post


Link to post
Share on other sites
Can you give some a more detailed location for a noob on where the documentation is and how to access it?

So far the only documentation I can find is within the function headers, and you can find them in the OA modules PBO, under the directory "scenes". You can also find some of those headers here.

Share this post


Link to post
Share on other sites

Wow this sounds awesome, good finding Big_Dawg. I haven't looked at it, can you determine when the "recorded movement" is over?

Share this post


Link to post
Share on other sites

For the UnitCapture function, you pass a duration as an argument. It will stop recording either after this duration, when you press Esc, or when the unit dies. IIRC you can also skip into a certain frame when playing it back, and there's probably a way to end it early.

There's also a UnitCaptureSimple function where it stops when you press Esc or the unit dies. Corresponds with UnitPlaySimple, which probably doesn't have all those above features.

Edited by Big Dawg KS

Share this post


Link to post
Share on other sites

So I know nothing at all about BIS functions such as these, do I place the call in a script or trigger? Or console?

Share this post


Link to post
Share on other sites

Well it doesn't really matter where you call it from, as long as it gets executed with the correct arguments.

I would probably use a radio trigger for calling the capture function, just so I can start it whenever I want. As for the play function, depends entirely on when/how you want it to execute.

When I get home I'll definately try using these. If I can figure it out, I'll throw together a demo mission or something.

Share this post


Link to post
Share on other sites

Didn't seem to work for me, so I'll just wait for that demo mission.

In a trigger, I put

[test] call BIS_fnc_UnitCapture; hint "Activated";

in the activation. It would activate, I'd fly around for a few seconds, then land and tab out to Notepad, only to find there is nothing to Paste.

Share this post


Link to post
Share on other sites
;1666303']Didn't seem to work for me' date=' so I'll just wait for that demo mission.

In a trigger, I put

[test'] call BIS_fnc_UnitCapture; hint "Activated";

in the activation. It would activate, I'd fly around for a few seconds, then land and tab out to Notepad, only to find there is nothing to Paste.

Yea, there's probably a little more to it than that. Lemme take another look at that documentation.

---------- Post added at 01:59 PM ---------- Previous post was at 01:52 PM ----------

BIS_fnc_UnitCapture

Description:

Records movement data of input unit over a specified period of time.

Pressing the ESC key, the duration ending, or the unit dying ends

the recording.

Parameters:

Unit - Unit to capture movement data from

Duration - Duration to capture for

OPT:FPS - OPTIONAL: Frames recorded Per Second (default 20). Limit is 1 - 100

OPT:Firing - OPTIONAL: If true, will record the input unit's weapon fire data as well

OPT:StartTime - OPTIONAL: Starting time offset for the frame time

Ok. First you have to make sure the functions are compiled. Placing a Functions module will probably do the trick.

Next, when you call it:

[heli1,300] call BIS_fnc_UnitCapture

Will record heli1's movement for 300 seconds.

After 300 seconds, or when you press Esc, it should copy the data to clipboard, at which point you can alt-tab out and paste it into a file.

Now, to play it, assign that data to a variable (let's call it heliMoveData1), then call:

[heli1,heliMoveData1] call BIS_fnc_UnitPlay

Share this post


Link to post
Share on other sites

Well, I've got it working... Nearly... When I activate the Capture trigger game just freezes and stays that way for the time of capture... After, it shows me that the data was copied (which is true). But data is aquired from the beggining postion of the vehicle (which is one F*in place)...

Already had about 20 ideas how to use it, but it's just broke down for me somehow...

Share this post


Link to post
Share on other sites
;1666332']Well' date=' I've got it working... Nearly... When I activate the Capture trigger game just freezes and stays that way for the time of capture... After, it shows me that the data was copied (which is true). But data is aquired from the beggining postion of the vehicle (which is one F*in place)...

Already had about 20 ideas how to use it, but it's just broke down for me somehow...[/quote']

How did you call it? I'm thinking now you have to use spawn instead of call (though I thought the script spawned it's own thread, eh whatever).

Share this post


Link to post
Share on other sites

No, that's how it actually looks in the trigger Act. field:

[x1, 60, 30] call BIS_fnc_UnitCapture;

Oh, and after it's unfreezes I still can't control anything... Only menu works... And for example - the rotors in the chppper are static, although the grass is blown away...

Edited by Max255[PL]

Share this post


Link to post
Share on other sites

So I got data and the paste worked, but I'm having the same issue as Max.

Share this post


Link to post
Share on other sites

Have you guys tried using 'spawn' instead of 'call'? Ex:

rec = [x1, 60, 30] spawn BIS_fnc_UnitCapture;

Share this post


Link to post
Share on other sites

Woop, it works...

Just missed that "rec =" thing...

Share this post


Link to post
Share on other sites

Wow, yeah, worked for me to. This is really cool.

I didn't even need the 'hint "Activated"' deal because when it 'spawns' the function it hints you saying that it started, and to hit ESC when done. Once you complete it, another large hintsilent comes up giving statistics of the recording and says to hit F1 to copy to clipboard, and the paste worked. Thanks!

Share this post


Link to post
Share on other sites

Excellent. You guys go and record lots of nice moves, then share them with the rest of us. We can see who's got the best moves. ;)

Share this post


Link to post
Share on other sites

Another issue, can't play it... Any quick, easy steps? Just tell me from the start, what I need to do...

Share this post


Link to post
Share on other sites

UnitPlay isn't working for me either haha. Tried with spawn and with call from a trigger, but still nothing. Is there anything that I have to do to the .sqf file other than paste the data?

Share this post


Link to post
Share on other sites

After 300 seconds, or when you press Esc, it should copy the data to clipboard, at which point you can alt-tab out and paste it into a file.[/code]

What do you mean with file ?

A .txt or .sqf ?

So i can record a landing and then let the helicopter fly away to a waypoint ?

1. Recorded landing scene

2. All units get out

3. helicopter flys away to a waypoint and is deleted

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×