Jump to content
SkaceKachna

How to stop camera commiting?

Recommended Posts

Hello,

 

is there any way to stop camera mid-commit? For example I call:

GCAM camSetPos SOMEWHERE_FAR;
GCAM camCommit 100;

then player performs an action and I want the camera stop moving to the target position and move somewhere else.

I've tried to simply call:

GCAM camCommit 0;

which does nothing (the commits stack?).

 

I've also tried to destroy the camera, which works, but I'm unable to recreate it at same position and rotation.

Following works, with the exception of direction, which is incorrect, the camera is looking somewhere completely else when restored:

// Save camera position and direction
private _pos = getPos(GCAM);
private _dir = vectorDir(GCAM);

// Destroy camera
GCAM cameraEffect ["terminate","back"];
camDestroy GCAM;

// Create new camera and assign the position and direction
call createGCAM;
GCAM camSetPos _pos;
GCAM camSetDir _dir;
GCAM camCommit 0;

Anyone has experience with this? Any method to clear commits? Or any way to "clone" the camera properly?

 

Thanks

Share this post


Link to post
Share on other sites

did you try to give it a new target and position and do another camCommit?

Share this post


Link to post
Share on other sites

It looks like you're using a 3rd party camera script, GCAM. It works differently.

 

The command camCommit does not stack. In fact, if you have multiple camera shots in a script, the 2nd one will overwrite the first one UNLESS you have waitUntil { camCommitted _camera } after the camCommit line. If GCAM is not working that way, you need to post to that author's thread.

 

Share this post


Link to post
Share on other sites
4 hours ago, .kju said:

did you try to give it a new target and position and do another camCommit?

 

I'll try that.

 

1 hour ago, AZCoder said:

It looks like you're using a 3rd party camera script, GCAM. It works differently.

 

The command camCommit does not stack. In fact, if you have multiple camera shots in a script, the 2nd one will overwrite the first one UNLESS you have waitUntil { camCommitted _camera } after the camCommit line. If GCAM is not working that way, you need to post to that author's thread.

 

 

GCAM is just variable I used example (short for GlobalCam), i'm using vanilla cameras. Maybe I have some concurrency issue, but from the behaviour I observed, it seems like they stack.

Share this post


Link to post
Share on other sites

OK,

so seems like calling camSetPos and camSetTarget before calling camCommit actually stops previous commit and makes camera follow new orders. (so the note here is that you can't just call camCommit without changing anything before).

BUT it breaks the camCommitted command, which actually waits for the first commit to finish. I suppose that is a bug?

Attached is minimal reproduction mission. The camera should be destroyed upon reaching the target, but it waits until the first commit is done...

 

cameraTest.Altis.zip

Edited by SkaceKachna
forgot the test mission

Share this post


Link to post
Share on other sites

Use camCommitPrepared. Now that I'm home and looking at my scripts, what I wrote earlier was wrong memory under work stress. Here's an example:

 


_camera camPrepareTarget [-59329.74,81125.10,3497.26];
_camera camPreparePos [2198.69,2385.89,1.60];
_camera camPrepareFOV 0.700;
_camera camCommitPrepared 32;
waitUntil {camCommitted _camera};

 

And generally speaking, you should use a local var. GCAM could get overwritten by other scripts and/or threads.

And gcam is literally a mod, so you can't blame me ;)

http://www.armaholic.com/page.php?id=23296

 

Hey I just looked at your sample script. Actually that works fine (and local _cam good), you were just missing one line in this section:


_cam camSetPos _p2;
_cam camSetTarget _p2;
_cam camCommit 10;
waitUntil { camCommitted _cam }; // I added this line

 

 

Share this post


Link to post
Share on other sites

( yea, I choose wrong name for the example scripts, I can see how you can be confused by that :) )

 

Well, that's the point, I don't want to wait for the first commit to finish. I want to cancel it and create new commit. Right now, it seems like the only way to achieve this is by using sleep instead of camCommitted, because the camCommited will wait for the longest commit, not the latest commit as demonstrated in the example mission.

 

So if you do:

_cam camSetPos _p2;
_cam camCommit 100;

sleep 2;

_cam camSetPos _p3;
_cam camCommit 1;

waitUntil { camCommitted _cam };

You will end up waiting for 100 seconds, instead of 3, despite the first commit not actually doing anything...

 

Also, I tried using camPrepare* commands, but they have the same behaviour.

Share this post


Link to post
Share on other sites

Ok I see what the objective is here, had to recheck the first post again. You want the camera to move at a leisurely rate to some position, but stop if the player does some action. Destroying and recreating the camera is not providing the same angle, causing a visual glitch. I use while loops frequently to move the camera around moving vehicles and can interrupt it anytime I want because I use a 0 commit time, but that might be hard to apply to your scenario. I would have to look over my scripts when I'm at home to see if that could work for you or not. But yes you're correct about the camCommit time, I don't know of an interrupt for it short of camDestroy.

 

(10 hours later)

I looked at my scripts and played around a bit, but I don't have a good solution for you, sorry.

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

×