Jump to content
Sign in to follow this  
stingfish74

Camera to follow a rocket

Recommended Posts

is it possible to have a camera follow a rocket fired from a AT launcher OR a vehicle AND follow the projectile in slow motion?

if possible, please post a step by step instruction

Share this post


Link to post
Share on other sites

Yes.

unit addeventhandler ["fired",{_this execVM "cam.sqf"}]

cam.sqf:

_projectile = nearestobject [_this select 0,_this select 4];
_list = ["R_M136_AT","M_Javelin_AT","M_Stinger_AA","R_PG7V_AT","R_PG7VR_AT","M_Strela_AA","R_Hydra_HE","R_57mm_HE","R_80mm_HE","M_Sidewinder_AA","M_TOW_AT","M_AT5_AT","M_Hellfire_AT","M_Vikhr_AT"];
if((_this select 4) in _list)then{
setacctime 0.5;
_camera = "camera" camCreate [0,0,0];
_camera cameraeffect ["internal", "back"];
while{alive _projectile && alive _camera}do{
_camera camSetTarget _projectile;
_camera camSetRelPos [0,-13,1.2];
_camera camCommit 0;
sleep 0.001;
};
if(alive _camera)then{sleep 1};
_camera cameraeffect ["terminate", "back"];
camdestroy _camera;
setacctime 1;
};

Edited by Big Dawg KS
  • Like 1

Share this post


Link to post
Share on other sites

I can't get it to work... dont get an error but just dosent follow rockets etc.

Share this post


Link to post
Share on other sites

Open Notepad and paste the code sample found in KyleSarnik's post. Then save it as cam.sqf. Remember to select "all files" when saving, or it will be saved as cam.sqf.txt instead.

Put the cam.sqf in the same folder as your mission. Probably something like this: C:\Documents and Settings\Your Name\My Documents\ArmA\missions\Mission Name.Sara

In the editor open your mission and add this to the unit's initialization field:

unit addeventhandler ["fired",{_this execVM "cam.sqf"}]

Be aware that the unit's name in this example is unit. You may name it anything you like, but don't forget to name it.

Hope this helps!

And a big thanks to KyleSarnik for this wonderfull code. I'm now able to add "bullet camera" to the player in a mission I'm working on. Great!

Share this post


Link to post
Share on other sites

It will work on everything you select in list.

See this line of code:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_list = ["R_M136_AT","M_Javelin_AT","M_Stinger_AA","R_PG7V_AT","R_PG7VR_AT","M_Strela_AA","R_Hydra_HE","R_57mm_HE","R_80mm_HE","M_Sidewinder_AA","M_TOW_AT","M_AT5_AT","M_Hellfire_AT","M_Vikhr_AT"];

Add here the ammunition type that weapon uses. You'll find the class here.

I've tried this nice script (big thanks to KyleSarnik) for following bullets, but I had some strange camera positions (it looked like underground or something).

If someone find solution let me know wink_o.gif

Share this post


Link to post
Share on other sites

just as a FYI...

I added the ammo for the Dragunov sniper rifle. note that my weapons config is mod'ed and bullet deflection = 30%.

using kyles script, i was able to see that bullets infact DO defelect multi times.

i fired @ a building, camera followed the projectile, deflected off that building, hit another building deflecting AGAIN, into the ground.

pretty neat

Share this post


Link to post
Share on other sites

Superb, I was just dreaming off having some "Matrix effect" when I saw this topic, many thanx!

Share this post


Link to post
Share on other sites

works fine. There seems to be a bug tho, the first rockect fired sets a camera somewhere in the sea, Rockets fired after that work fine.

Share this post


Link to post
Share on other sites

loving the script smile_o.gif

i do have a problem if i fire at a target benathe me E.G. a tank on a hill fires at a building below it the camera jumps to the sea instead of the shell but othrwise its fine. if anyone knows how to get rid of this problem id much apprecitate it.

Share this post


Link to post
Share on other sites

Going to try this right away, I wonder how it will work with 203 grenades...

Share this post


Link to post
Share on other sites
Ha, it worked? Man how's that for you, I just came up with it on the fly.  tounge2.gif  Glad it works.

notworthy.gifwink_o.gif

Share this post


Link to post
Share on other sites

Modified version of KyleSarniks script, might fix some issues with the camera appearing at the sea. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_projectile = nearestobject [_this select 0,_this select 4];

_list = ["R_M136_AT","M_Javelin_AT","M_Stinger_AA","R_PG7V_AT","R_PG7VR_AT","M_Strela_AA",

"R_Hydra_HE","R_57mm_HE","R_80mm_HE","M_Sidewinder_AA","M_TOW_AT","M_AT5_AT","M_Hellfire_AT","M_Vikhr_AT"];

if((_this select 4) in _list)then{

setacctime 0.5;

_camera = "camera" camCreate (getpos _projectile);

_camera cameraeffect ["internal", "back"];

while{alive _projectile && alive _camera}do{

_camera camSetTarget _projectile;

_camera camSetRelPos [0,-13,1.2];

_camera camCommit 0;

sleep 0.01;

};

if(alive _camera)then{sleep 1};

_camera cameraeffect ["terminate", "back"];

camdestroy _camera;

setacctime 1;

};

Or this version if you want the camera to follow anything you fire, including bullets (also based on KyleSarnik's script):

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_projectile = nearestobject [_this select 0,_this select 4];

setacctime 0.2;

_camera = "camera" camCreate (getpos _projectile);

_camera cameraeffect ["internal", "back"];

while{alive _projectile && alive _camera}do

{

_camera camSetTarget _projectile;

_camera camSetRelPos [0,-13,1.2];

_camera camCommit 0;

sleep 0.01;

};

if(alive _camera)then{sleep 1};

_camera cameraeffect ["terminate", "back"];

camdestroy _camera;

setacctime 1;

You can change the number after the 'setacctime' command at the start of the script to whatever you want to control the slow motion effect. 1 is normal time speed, 0.5 is half, 2 would be double ect. Don't change the second one at the end, that just sets it back to 1 when the script ends.

Edit: Also remember this in the unit's init line:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addeventhandler ["fired",{_this execVM "cam.sqf"}]

And call the script file "cam.sqf".

And of course it goes in the folder for your custom mission.

Share this post


Link to post
Share on other sites

MaddMatt, I just had a chance to test out the above script and it's awesome! Thank you. I changed a couple things most notably the setacctime and the sleep time which made the effect really smooth. This is the resulting script!

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_projectile = nearestobject [_this select 0,_this select 4];

setacctime 0.55;

_camera = "camera" camCreate (getpos _projectile);

_camera cameraeffect ["internal", "back"];

while{alive _projectile && alive _camera}do

{

_camera camSetTarget _projectile;

_camera camSetRelPos [0,-13,1.2];

_camera camCommit 0;

sleep 0.001;

};

if(alive _camera)then{sleep 1};

_camera cameraeffect ["terminate", "back"];

camdestroy _camera;

setacctime .97;

exit

I always use .97 acctime smile_o.gif This script is perfect for target ranges! w00t

Share this post


Link to post
Share on other sites

I tried this word for word, made a text doc and saved it as cam.sqf/all files, put it in my documents folder of my custom mission. Opened the editor and added an AT Specialist

added this in the initialize line <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addeventhandler ["fired",{_this execVM "cam.sqf"}

To no avail... Error after error Missing; started it, Then there was Type Bool,Expected Nothing, Then there was something about a wrong number in something PFFT I dunno!!!

What am I doing wrong?!?

Well I think I figured part of it out but when the game loads and the first round is fired it now pops up the error Scripting cant load cam.sqf

Im using version 1.18 the latest update dont know if that helps any

Edited by Lionwayt

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  

×