Jump to content
Sign in to follow this  
IndeedPete

Campscript on Airplane - Camera Glitches

Recommended Posts

Hi there,

I'm having troubles getting a camscript to do what I want. I basically attach a camera to a flying airplane. I guess because of the speed it starts glitching, i.e. the airplane is too fast and the camera can't update its position quick enough. There have been similar observations with no solution here. I've already tried to limit the speed to 100 KPH but they won't go slower than 215. It's not that much of a problem when filming the plane from behind, but it becomes a really ugly phenomenon when you try shots from the front or side. Anybody got ideas for another workaround?

For testing and reference here's a WIP script snippet which works from the debug console provided you have placed the three markers "mHQ", "mPlane1" and "mPlane2":

handle = [] spawn {
["IP_BlackScreen", false] call BIS_fnc_blackOut;
sleep 0.5;

_posTarget = getMarkerPos "mHQ";
_posStart = getMarkerPos "mPlane1";
_dir = [_posStart, _posTarget] call BIS_fnc_dirTo;
_grp = createGroup west;
_grp setGroupID ["Badass One"];

IP_Pilot = _grp createUnit ["B_Pilot_F", _posStart, [], 0, "NONE"];
IP_Pilot setRank "CAPTAIN";

IP_Plane = createVehicle ["B_Plane_CAS_01_F", _posStart, [], 0, "FLY"];
IP_Plane setDir _dir;
IP_Pilot moveInDriver IP_Plane;
IP_Plane enableSimulation false;

_wp = _grp addWaypoint [_posTarget, 0];
_wp setWaypointType "SAD";
[_grp, 0] setWaypointBehaviour "COMBAT";
[_grp, 0] setWaypointCombatMode "RED";

_posStart = getMarkerPos "mPlane2";
_grp = createGroup west;
_grp setGroupID ["Badass Two"];

IP_Pilot2 = _grp createUnit ["B_Pilot_F", _posStart, [], 0, "NONE"];
IP_Pilot2 setRank "LIEUTENANT";

IP_Plane2 = createVehicle ["B_Plane_CAS_01_F", _posStart, [], 0, "FLY"];
IP_Plane2 setDir _dir;
IP_Pilot2 moveInDriver IP_Plane2;
IP_Plane2 enableSimulation false;

_wp = _grp addWaypoint [_posTarget, 0];
_wp setWaypointType "SAD";
[_grp, 0] setWaypointBehaviour "COMBAT";
[_grp, 0] setWaypointCombatMode "RED";

_camera = "camera" camCreate (getPos player);
_camera cameraEffect ["internal", "back"];

IP_InCutscene = true;

_camera spawn {
	while {IP_InCutscene} do {
		_this camSetTarget IP_Plane;
		_this camSetRelPos [-5, 10, -1];
		_this camPrepareFOV 0.700;
		_this camCommitPrepared 0;
		{_x limitSpeed 100} forEach [iP_Plane, IP_Plane2];
	};
};

{
	_x enableSimulation true;
	_x setVelocity [100 * (sin _dir), 100 * (cos _dir), 0];
} forEach [iP_Plane, IP_Plane2];

sleep 0.5;
["IP_BlackScreen"] call BIS_fnc_blackIn;
};

As usual, any ideas are appreciated!

Share this post


Link to post
Share on other sites

I've used cameras on planes, with no problems whatsoever, with something similar:

_camera spawn 
{
while {IP_InCutscene} do
{
	_this camSettarget IP_Plane; 
	_this camsetrelpos [1, 30, 0.5]; 
	_this camCommit 0; 
	sleep 0.005;
};
};

Pretty much the same with a sleep added. Not sure about how fast it was going, though.

Share this post


Link to post
Share on other sites

Thanks, I've played around a bit and when they're slow enough there are less glitches, it's even viewable by now. Still strange behaviour.

Share this post


Link to post
Share on other sites

Hi IP

Instead of a while loop in a spawned thread where you are possibly held up by the scheduled environment. Have you tried an onEachFrame or missionEventHandler "Draw3D" instead?

Share this post


Link to post
Share on other sites

Hm, onEachFrame might be an option too. In some cases the is already an onEachFrame handler running during the mission. But I could disable it during the cutscene. Thanks, I'll try that!

Share this post


Link to post
Share on other sites

If you already have an onEachFrame then adding another is not a problem as you should really be using addStackedEventHandler for compatibility as documented in the stickies in the top of this forum.

Share this post


Link to post
Share on other sites

I know but it just reminded me that I have to disable the other onEachFrame EH as it's messing around with the GUI which is something I don't want during a cutscene anyway.^^

Share this post


Link to post
Share on other sites

I vaguely remember having that issue in ArmA 2, I fixed it by attaching a game logic to the plane, and using that logic as cam base/attach/target instead of the plane itself. I got rid of the shakiness that way. Maybe worth a try.

Share this post


Link to post
Share on other sites

Interesting idea, thanks for sharing. I'll try the stacked EH first, maybe that's enough already.

Share this post


Link to post
Share on other sites

The stacked EH does its job perfectly, thanks to you all!

Share this post


Link to post
Share on other sites
I vaguely remember having that issue in ArmA 2, ...

Yeah, I too remember my cam scripts beginning to stutter/shake at some point in A2.

However, I've fixed it by simply removing the tiny sleep in the loop - without sleep, things ran fine again.

Share this post


Link to post
Share on other sites
The stacked EH does its job perfectly, thanks to you all!

Can you post your solution?

Share this post


Link to post
Share on other sites

Probably something like...

["planeCam", "onEachFrame", { 
_cam camSetTarget thePlane;
_cam camSetRelPos [-5, 10, -1];
_cam camPrepareFOV 0.700;
_cam camCommitPrepared 0;
}] call BIS_fnc_addStackedEventHandler;

Share this post


Link to post
Share on other sites

Ah, sorry, forgot to post that. Yes, it's something along those lines. ;)

_scene = {
IP_Camera camSetTarget IP_Plane;
IP_Camera camSetRelPos [-5, 10, -1];
IP_Camera camPrepareFOV 0.700;
IP_Camera camCommitPrepared 0;
};
["IP_OnEachFrameEH", "onEachFrame", _scene] call BIS_fnc_addStackedEventHandler;

Share this post


Link to post
Share on other sites
Ah, sorry, forgot to post that. Yes, it's something along those lines. ;)

_scene = {
   IP_Camera camSetTarget IP_Plane;
   IP_Camera camSetRelPos [-5, 10, -1];
   IP_Camera camPrepareFOV 0.700;
   IP_Camera camCommitPrepared 0;
};
["IP_OnEachFrameEH", "onEachFrame", _scene] call BIS_fnc_addStackedEventHandler;

I'm still getting lots of stuttering with this method. Can it be something else? I also tried using camCommitPrepared with 0.5 as I've seen suggested elsewhere to smooth things out a bit but still stuttering.

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  

×