Skip to content

Question about SetCameraFacing timing

Hello!

Is there any documentation about how the SetCameraFacing function determines how fast to change the direction/distance/pitch values?

From trial-and-error, I can see that the direction change is using the Camera Transition Type value (_SLOW moves at a steady 20 degrees/second, _VERY_SLOW at 5 degrees/second, etc.), at least when I am only changing the direction.

The pitch changes at a slower speed: _SLOW seems to be around 10 degrees/second, but sometimes seems more like 9.7 or so degrees/second.

The camera also seems to sometimes slow down if it happens to pass through "architecture", though that might just be due to extra calculations.

Basically, when setting up a cutscene with camera movements, it would be very useful to be able to calculate how much time the camera will take to complete its movement.

Alternatively, if I could have the cutscene wait until the camera motion is finished before continuing, that would also work. I haven't had any luck getting this to happen, though - it seems like once the camera is in motion, it just keeps going until it stops.

Any help would be greatly appreciated!

Comments

  • TarotRedhandTarotRedhand Member Posts: 1,481
    edited March 2022
    The only documentation I am aware of is to be found in the Lexicon. AFAIK Beamdog hasn't altered this (I double checked in the wiki). So here are the constants in a table (taken from the Lexicon and rearranged so it goes from slowest to fastest) -
    CAMERA_TRANSITION_TYPE_* Constant Group
    
    Used with SetCameraFacing() to determine how smoothly to transition the camera.
    
    Constants
    
    Constant                          Value     Description
    CAMERA_TRANSITION_TYPE_CRAWL        2       Slowest camera transition.
    CAMERA_TRANSITION_TYPE_VERY_SLOW    5       Second slowest camera transition.
    CAMERA_TRANSITION_TYPE_SLOW         20      Slow camera transition.
    CAMERA_TRANSITION_TYPE_MEDIUM       40      Middle speed camera transition.
    CAMERA_TRANSITION_TYPE_FAST         70      Fast camera transition.
    CAMERA_TRANSITION_TYPE_VERY_FAST    100     Second fastest camera transition.
    CAMERA_TRANSITION_TYPE_SNAP         0       Snaps the camera immediately into place (fastest camera transition).
    

    For more control over the camera have you thought about using the (older) GestaltCamera Scripting System v2.0 or the (newer and expanded) Gestalt Cutscene Scripting System? If you decide to use the latter be aware that there is also an alternate set of instructions Gestalt Cutscene System - updated pdf by @jimdad55.

    TR
  • ProlericProleric Member Posts: 1,283
    For maximum control over camera timing, position and motion, I use the Gestalt Cutscene Scripting System.

    The GestaltCameraCrane() function is the most general.

    Since the camera timing is precisely specified, you can delay other actions to match.

    These days, I wouldn't consider writing a cutscene with the vanilla functions, because the Gesalt system has already ironed out all the bugs for us.
  • rjohnson674rjohnson674 Member Posts: 5
    Thank you for your feedback!
  • rjohnson674rjohnson674 Member Posts: 5
    In case anyone else wonders about this (and searches for this subject on these forums), I did manage to figure out how the SetCameraFacing function (apparently) works:

    When changing only the direction, the camera changes this angle at a steady rate equal to the value of the CAMERA_TRANSITION_TYPE_ constant passed to the function. So CAMERA_TRANSITION_TYPE_MEDIUM will have the direction change at 40 degrees per second. It moves in the shortest "distance" (clockwise or counterclockwise) to reach the target direction.

    When changing only the pitch, the camera again changes the angle at a steady rate, though this rate is 22/45 times the value of the CAMERA_TRANSITION_TYPE_ constant. As this works out to 88/180, I believe this rate was chosen so that the maximum angle change takes the same time for both direction and pitch - with the default camera limits, the maximum direction change is 180 degrees and the maximum pitch change is 88 degrees (between 1 degree and 89 degrees).

    When changing only the zoom distance, the camera moves exponentially, rather than linearly. In particular, Current distance = Start distance times a constant (seems to be about 1.0125) raised to an exponent that is the product of the CAMERA_TRANSITION_TYPE_ constant's value and the time that has passed since the motion started (use positive values for zooming out and negative values for zooming in). Going the other way, to calculate how long the camera needs to "zoom" from one distance to another, it is: time = (LOG(bigger distance) - LOG(smaller distance))/(CAMERA_TRANSITION_TYPE_ constant * LOG(1.0125)).

    When changing more than one of the parameters (direction, zoom distance, pitch) at once, the function seems to calculate how long each change would take, and uses the longest one. The other rates of change are slowed down so that they all finish at the same time.

    Finally, if the camera is still moving when a new SetCameraFacing command is issued, it immediately starts moving to the new angles/distance (does not finish the previous command).
Sign In or Register to comment.