Jump to content
gc8

Smooth camera

Recommended Posts

Hi

I am trying to create a camera that follows helicopter maybe in third person style. But haven't been able to figure how to make the camera to follow the helo smoothly. Can some one help?

 

Here's my camera code which is quite poor, I have tried different settings with it without satisfying result:

 

private _man = vehicle player; // Tried vehicle here

showCinemaBorder false;

_cpos = getpos _man;
_cam = "camera" camCreate _cpos;
_cam camSetTarget _man;

_cam camSetRelPos [2, 2, 2];

_cam cameraEffect ["internal", "BACK"];

_cam camCommit 0;

helocam = _cam;

[_cam,_man] spawn 
{
params ["_cam","_man"];
while { !isnull helocam } do
{
//_cam camSetPos (getpos _man);
_cam camSetRelPos [2, 2, 2];
_cam camCommit 2;
sleep 0.5;
};
};

 

thx!

Share this post


Link to post
Share on other sites

Use attachTo command to attach the cam to its target

Share this post


Link to post
Share on other sites

Ok I tried that but I get a lot of camera jitter

Share this post


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

 

With

 


_cam camSetPos (visiblePosition _man);

 

There's also jitter

Because you're setting the camera position every 0.5 seconds, of course it's not gonna look good.

Try using an eachFrame eventhandler to set the camera position.

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

As I said, lose that sleep. I did fail to mention that it works best with onEachFrame or an EachFrame EH, as GOM says.

Share this post


Link to post
Share on other sites

@gc8 Attach the camera to the helicopter, set the cameras target as the pilot or a unit within the helicopter.

I accept donations and gifts.

Share this post


Link to post
Share on other sites

Ok got it working. thx

Share this post


Link to post
Share on other sites
3 hours ago, gc8 said:

Ok got it working. thx

Always nice to post your final solution, so others might benefit instead of opening another thread to the same/similar problem.

 

Cheers

  • Like 2

Share this post


Link to post
Share on other sites

Yeah I think this is all you need for the camera (It's not perfect but shows how to do it)

 

showCinemaBorder false;

_cpos = getpos _helo;
_cam = "camera" camCreate _cpos;

_cam camSetTarget (driver _helo);

_cam camSetRelPos [0, -5, 7.5];

_cam cameraEffect ["internal", "BACK"];

_cam camCommit 0;

_cam attachTo [_helo];

 

_heli variable must be defined somewhere

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

×