OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: desrat on 25 Oct 2009, 12:46:37
-
I wondered if there is anyway to attach a camera to a chopper (or have it track from a simlilar view as 3rdperson) but force the camera to always face the direction the chopper is heading (boresighted).
I'm trying to create a custom benchmark to help me get the most from ArmA2 on my hardware...
-
camsestrelpos is what ya looking for i think.
http://community.bistudio.com/wiki/camSetRelPos
the figures in the [ ] are the position relative to the target .
-
Something like:
_cam camSetTarget mychopper;
while {true} do
{
_cam camsetrelpos [0,-20,0];
_cam camCommit 0;
Sleep 0.002;
};
-
Hey wait...aren't cameras objects that can often be manipulated more or less like any other object? Why not actually try attachTo? Just for a hoot! Sorry, cant test it myself now : Mandoble's solution would work otherwise.
Wolfrug out.
-
my apologies for the delay in responding - I actually ended up using a script given as an answer by Mandoble in another thread as it was pretty much what I needed - although I wouldnt mind seeing an attachto example as well...
//followplane.sqf
_plane = _this select 0;
keepfollowing = true;
_cam = "camera" camcreate [0, 0, 0];
_cam cameraeffect ["internal", "back"];
_relpos = [0, -5, 5];
_cam camSetRelPos _relpos;
_cam camSetTarget _plane;
_cam camSetFov 1;
_cam camCommit 0;
while {keepfollowing} do
{
_cam camSetRelPos _relpos;
_cam camCommit 0.2;
Sleep 0.01;
};
_cam cameraeffect ["terminate", "back"];
camDestroy _cam;
executed from init.sqf
res = [chopper] execVM "followplane.sqf";
-
attachto would be more or less the same as relpos to be honest , with the added option of using a selection position to define where the cam is attached.
without trying in game it would be something like
//followplane.sqf
_plane = _this select 0;
keepfollowing = true;
_cam = "camera" camcreate [0, 0, 0];
_cam cameraeffect ["internal", "back"];
//_relpos = [0, -5, 5];
//_cam camSetRelPos _relpos;
_cam attachto [_plane,[0, 0,0]];
// you could find a selection pos too i guess if it works [_plane,[0, 0,0],"zeleny pozicni"]
_cam camSetTarget _plane;
_cam camSetFov 1;
_cam camCommit 0;
sleep 12;
_cam cameraeffect ["terminate", "back"];
camDestroy _cam
i have left out your while loop but you can put it back in , i am not sure what you would want in there because your relpos would be redundant using attachto. maybe just
while {keepfollowing} do
{
Sleep 0.01;
};
will do for now.
try that and especially the selection pos and let me know, i might find a need for it myself if it works.
DB
-
well it worked and actually better than the setrelpos version (much smoother) also got rid of camSetTarget to ensure a forward facing camera - example attached
//followplane.sqf
_plane = _this select 0;
keepfollowing = true;
_cam = "camera" camcreate [0, 0, 0];
_cam cameraeffect ["internal", "back"];
_cam attachto [_plane,[0, 5,0]];
_cam camSetFov 1;
_cam camCommit 0;
while {keepfollowing} do
{
Sleep 0.01;
};
_cam cameraeffect ["terminate", "back"];
camDestroy _cam
-
interesting.
im updating my tv guided script and moving from switchcamera to camera.
camSetRelPos will not work for me.. but the attachto command would if i could get it to work.
problem. i cant attach the camera to my bombs/missiles.
can anyone test out and see if they can attach a camera to a ammo type? because i cant get it to work :(
-
Didnt test it, but might be you can attach the camera to a GL, and then attach the GL to the ammo (in case ammo accepts attachto with GLs).
-
thanks for the suggestion. but it didnt work.
i tried creating a new bomb instead of grabing the fired one. but no go.
also tried with
_logic attachto [_bomb,[0,0,0],"gbu12"];
and
_logic attachto [_bomb,[0,0,0],"component01"];
seams like its not possible. or atleast i cant make it happen :weeping:
-
hmm thats strange ,
i have attached ammo to a vehicle before ,so attachto does work with ammo the other way round ( atached two aa missiles to a hmmv to make it look like a rocket car for a laugh).
I will have a go when i get home , i am not sure what memmory point ammo have to attach to but have you tried without the memmory points ? just a simple [_bomb,[0,0,0]] ?
EDIT
Tried it with created ammo , wouldnt attach ,must be a class thing i guess, i will enjoy trying to get a worrk around tho , its the best thing in bis games :)