Jump to content
Sign in to follow this  
iillusions

Script help | Camera follow rocket

Recommended Posts

Hello everyone, I'm in need of your assistance. I'm trying to create a script that triggers a camera to appear and follow the rocket or bullet when I shoot with the MAAWS MK14 or any other weapon. However, I'm encountering some errors for some reason the code doesn't work, and I would greatly appreciate your help.

Here are the details of the script and my setup:

I followed the steps from this post: camera-to-follow-a-rocket post
error image: link

 

• My player variable name is "unint" (I'm unsure if this is relevant, but thought I'd mention it).

• In the init box, the following code is used (the last line is for calling the camera follow, everything above is for infinite ammo):

this addEventHandler [
  "Fired",
  {
    if ((_this select 5) == "MRAWS_HEAT_F") then
    {
      player addMagazine "MRAWS_HEAT_F";
    };
  }
];
this addeventhandler ["fired", {(_this select 0) setvehicleammo 1}];
[this, 20] call BIS_fnc_traceBullets;

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

• In my mission file, I've created an SQF file named "cam.sqf, the following code is inside cam.sqf.

<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;


If you could provide assistance with resolving the issues I'm encountering, I would be extremely grateful.

Share this post


Link to post
Share on other sites
2 hours ago, iillusions said:

Hello everyone, I'm in need of your assistance. I'm trying to create a script th

-Close-
I was able to get it to work.
Thanks anyway 

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  

×