Jump to content
Sign in to follow this  
jedra

Spawn a helo with camera

Recommended Posts

Hi,

In the campaign you can buy upgrades to your helicopters such as cameras and the like. I was wondering how I would spawn a helicopter with a camera and display unit.

In the campaign with the heavy you can assist your landings with the camera. I want to try and spawn a similarly equiped heavy in a mission.

I have had a look through the configs for the helicopters and the comman list and the functions but I can't seem to find anything.

Anyone know how to do this?

Share this post


Link to post
Share on other sites

Thanks BeePee - didn't expect to find anything in 'Doors Off' and my search returned nothing.

Anyway, I can see how to add a camera now so thanks. Getting it to display something is a whole different ballgame - I just had a look at camera.fsm in the whale watching mission and it blew my mind!!

Share this post


Link to post
Share on other sites

Ok this is what I have be able to display so far.

Based on the http://community.bistudio.com/wiki/BIS_fnc_PIP

Disclaimer, these are results of experimenting, so aspects of this could easily be wrong.

That said, these snippets of code will allow people to quickly create something to display on a monitor. Even if it is for just a bit of fun.

Below is my attempt at a sling load camera, I used this as the base of what I used in my sling load addon. Copy and paste this into the helicopters init field.

By replacing rendertarget0 with rendertarget1 will display the cam in the copilots monitor on the heavy helicopter.

sr1 = this spawn

{
helipad1 = createvehicle ["Helipad_invisible_h", [0,0,0],[],0,"NONE"]; 
sleep 0.1;
helipad1 attachto [_this,[0,7,-30]];
_cam_loc = (_this selectionposition "slingload0");
_cam_loc_adj = [_cam_loc select 0,(_cam_loc select 1)-0.5,(_cam_loc select 2)- 0.1];
sling_cam = ["rendertarget0",[[_this,_cam_loc_adj ],helipad1 ],_this,true] call BIS_fnc_PIP;

sling_cam camPrepareFOV 0.7;
sling_cam camCommit 0;
};

This will turn off the pip. If you change vehicles, without switching it off, then it will appear in the new vehicle. Like themaster303 found when he had a sling cam in the driver side mirror on his suv.

[] call BIS_fnc_PiP;

Playing around I quickly modified it to attach the object the camera is focused on, onto a vehicle named car1. The camera will then track the vehicle. The other option is to track the vehicle directly. I manually placed the cameras position into the flir. There is probably a much better and more correct way to integrate these together?

sr1 = this spawn
{
helipad1 = createvehicle ["Helipad_invisible_h", [0,0,0],[],0,"NONE"];
sleep 0.1;
helipad1 attachto [car1,[0,0,0]];
_cam_loc = ( [0.7,0.84,-1.7]);
sling_cam = ["rendertarget0",[[_this,_cam_loc ],helipad1 ],_this,true] call BIS_fnc_PIP;

sling_cam camPrepareFOV 0.02;
sling_cam camCommit 0;
};
this animate ["AddTread", 0];
this animate ["AddFLIR", 1];
this animate ["AddMirror", 1];
this animate ["AddHoldingFrame", 1];

Hopefully somebody with more knowledge will dig up some harder facts to work with.

Share this post


Link to post
Share on other sites

Nice - something to play with. There is a lot of potential in some of the new ToH features - it's just a case of digging it out!

Anyway I will have a mess around with this later.

Share this post


Link to post
Share on other sites

hello BLAKEACE

how do you manage to switch from one to the other.

with trigger?waypoint?or no

excuse me but i am a newbie

Share this post


Link to post
Share on other sites
hello BLAKEACE

how do you manage to switch from one to the other.

with trigger?waypoint?or no

excuse me but i am a newbie

These are just snippets of stuff I was playing around with, more a starting point for others to experiment with.

One of the reasons I created the object helipad1 instead of at the object I wanted to follow, is it allows for changing where the camera points at easier by just moving the helipad object.

helipad1 attachto [car1,[0,0,0]];

Take the above line, you could create triggers to change what the camera is looking at by attaching the invisible helipad to different objects, or even just setting its' position somewhere important. The code will still run but the camera will point towards the new location.

For something more permanent it would be neater to create a script file and call the code from it rather than using the spawn command. I use it more for experimenting with ideas that I copy and paste into the editor.

E.g.

Create a mission and create a text file in the mission folder called something like tracking_Cam.sqf copy and paste in the code below.

_heli = _this select 0;
_cam_target = _this select 1;
//Line below used to terminate any existing PIP
[] call BIS_fnc_PiP;
helipad1 = createvehicle ["Helipad_invisible_h", [0,0,0],[],0,"NONE"];
sleep 0.1;
helipad1 attachto [_cam_target,[0,0,0]];
_cam_loc = ( [0.7,0.84,-1.7]);
sling_cam = ["rendertarget0",[[_heli,_cam_loc ],helipad1 ],_heli,true] call BIS_fnc_PIP;

sling_cam camPrepareFOV 0.02;
sling_cam camCommit 0;

_heli animate ["AddTread", 0];
_heli animate ["AddFLIR", 1];
_heli animate ["AddMirror", 1];
_heli animate ["AddHoldingFrame", 1];

Call the player helicopter "player_heli" without the quotes.

Create an object like a car and call it "car1" without the quotes.

Create a second object called "car2" without the quotes.

Then in a trigger or init.sqf or in the player helicopters init field add

si = [player_heli,car1] execVM "tracking_Cam.sqf";

In a trigger or actionmenu, add the following. This will cause the camera to follow the object called car2 now.

helipad1 attachto [car2,[0,0,0]];

You could change the other script snippet in a similar way, most important thing is to add.

[] call BIS_fnc_PiP;

This will clear any existing PIP first before creating something else.

Then using the likes of a trigger or an action menu you could run that code and the camera will change to a sling camera.

Alternatively if you wanted to have the existing flir camera point down to act like a sling camera you could just add something like;

helipad1 attachto [player_heli,[0,0,-30]];

Causing the camera to focus at a point 30m below the player helicopter.

For better clarity probably calling helipad1 something like PIP_target would be better. I didn't just for ease of copying and pasting :P

Hope this is a good starting point for you.

Blake.

Edited by blakeace

Share this post


Link to post
Share on other sites

Just wondering if anybody else has had a play around with the bis_fnc_pip function?

My issue is, if I call the function from within a spawn command, using the optional parameter 3

vehicle (Optional): Object - helicopter to which action is added (to memory point "action_screen1")

I get the camera's view in the helicopters monitor "rendertarget0". I also get the action screen overlay plus the action buttons to toggle the actionscreen off and on.

If I try and call the function using the same variables within a script, or addon, I fail to get the action screen or the action buttons to toggle it off and on. The camera view does display in the helicopters monitor "rendertarget0". Examples of both would be my posts above.

I have had a nose around in the function and it seems to call itself multiple times to enable all the components, but I have as yet not seen why I get different results. I have been able to hack it apart and enable the action screen and action buttons, though I am probably bypassing many of the safety checks built into the function.

So far I have been unable to resolve if it is my incorrect interpretation of the function, or something within the function causing this?

actionscreen.jpg

As a bonus for those that made it to the end :)

Quick prototype of a PIP flyby script, place this code in your helicopters initialization field. You must have pip enabled.

si = this spawn
{

_campos = (_this modeltoworld [50,150,20]);
_camera = "camera" camCreate _campos ;
_camera camPrepareFov 0.12;
_camera camPrepareTarget _this;
_camera camCommitPrepared 0;
_camera cameraEffect ["INTERNAL", "BACK", "rendertarget10"];

sleep 0.1;

[objnull,objnull,-1,[1,"rendertarget10"]] call bis_fnc_pip;

while {alive _this} do
{
if(speed _this > 0) then
{
	_campos = (_this modeltoworld [50,150,20]);
}
else
{
	_campos = (_this modeltoworld [50,-150,20]);
};
if((_this distance _camera)>160) then
{
	_camera  setpos _campos ;

}; 
sleep 1;
};

};



Edited by blakeace

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  

×