PDA

View Full Version : camera to follow anything you fire



yyccccc
Jun 9 2009, 06:53
Code Sample

_projectile = nearestobject [_this select 0,_this select 4];
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.001;
};
if(alive _camera)then{sleep 1};
_camera cameraeffect ["terminate", "back"];
camdestroy _camera;
setacctime 1;


Edit: Also remember this in the unit's init line:
Code Sample

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


question 1 : sometimes the camera appearing at the sea, what is the matter?
question 2 : when I play as a M1A1 gunner how can I stop friendlyAi from using the camera follow script?

Dr_Eyeball
Jun 9 2009, 07:39
1. You cannot always guarantee that the projectile will be found. If it's not found, then getPos will be [0,0,0] which is at sea.
Unfortunately they didn't add the extra param's of vbs2 in fired EH (http://community.bistudio.com/wiki/VBS2:_Event_Handlers#Fired).
Add a safeguard:

if (isNull _projectile) exitWith {player sideChat "Projectile could not be tracked"};
2. Add a check something like:

if (gunner (_this select 0) != player) exitWith {};