|
This function causes the camera to track an object, turning the camera to face that object regardless of where the player or the target object moves during this time. Here is an example of how the function can be called from your own script -
#include "in_g_cutscene"
void main()
{
object oPC = GetFirstPC();
object oWPStart = GetWaypointByTag("wp_start");
object oWPEnd = GetWaypointByTag("wp_end");
object oMilitia = GetObjectByTag("militia");
GestaltStartCutscene(oPC, "trackcam");
GestaltActionJump (0.0, oMilitia, oWPStart);
GestaltActionMove (0.5, oMilitia, oWPEnd);
GestaltCameraTrack (0.5,
oMilitia,
15.0, 50.0,
15.0, 50.0,
10.0, 20.0,
oPC, 0);
GestaltStopCutscene (11.0, oPC);
}
Most of this code is nothing to do with the GestaltCameraTrack function itself, it's setting up the militiaman to move from his starting waypoint to his destination waypoint. We teleport him to his start point, wait 0.5 seconds, then tell him to walk to his destination. Here's what the bit inside the GestaltCameraTrack() section of the script does -
This means that the example script above is telling the camera to track an object tagged "militia", with the camera staying 15.0 units from the player and 50.0 degrees from the vertical throughout the movement. It continues tracking the target for 10.0 seconds, moving the camera 20.0 times per second to give as smooth a motion as possible. The last two lines show that the movement is only applied to the first player in the player list and that only their camera is being rotated to face the target - their character keeps facing in the same direction throughout.
Here are a few more example scripts. Feel free to edit the camera test module to replace the existing g_trackcam function with the code samples listed below to see what they do, or try experimenting with it yourself.
#include "in_g_cutscene"
void main()
{
object oPC = GetFirstPC();
object oWPStart = GetWaypointByTag("wp_start");
object oWPEnd = GetWaypointByTag("wp_end");
object oBanner = GetObjectByTag("ct_banner3");
GestaltCameraTrack (0.0,
oBanner,
15.0, 50.0,
15.0, 50.0,
10.0, 20.0,
oPC);
}
This is similar to the first sample script, except that this time we are starting the camera movement instantly and focusing the camera on a stationary object (the banner) while allowing the player to run around freely. Note that because we're leaving both the integer options at their default values we don't have to list them when we call the function - the game will fill in the blanks.
#include "in_g_cutscene"
void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC))
{ return; }
object oWPStart = GetWaypointByTag("wp_start");
object oWPEnd = GetWaypointByTag("wp_end");
object oMilitia = GetObjectByTag("militia");
GestaltActionJump (0.0, oMilitia, oWPStart);
GestaltActionMove (0.5, oMilitia, oWPEnd);
GestaltCameraTrack (0.5,
oMilitia,
15.0, 50.0,
15.0, 50.0,
10.0, 20.0,
oPC));
}
This script again tracks the militiaman from the original sample script, but also allows the PC to run around freely. Notice what happens when both the player and the militiaman are moving - the camera has difficulty keeping track of two objects which are both moving unevenly. This is why this function is best used when either the player or the target is stationary.
#include "in_g_cutscene"
void main()
{
object oPC = GetPCSpeaker();
object oWPStart = GetWaypointByTag("wp_start");
object oWPEnd = GetWaypointByTag("wp_end");
object oMilitia = GetObjectByTag("militia");
GestaltStartCutscene(oPC, "trackcam", TRUE, TRUE, TRUE, TRUE, TRUE, 1);
GestaltActionJump (0.0, oMilitia, oWPStart);
GestaltActionMove (0.5, oMilitia, oWPEnd);
GestaltCameraTrack (0.5,
oMilitia,
15.0, 50.0,
10.0, 35.0,
10.0, 20.0,
oPC,
1, 1));
GestaltStopCutscene (11.0, oPC, "", TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, 1);
}
Here we have locked the player down again and are focusing once again on the moving militiaman. We've also added two more things to this script though. Firstly the start and end camera positions are now different - the camera zooms in slightly from 15.0 to 10.0 units from the player and tilts up from 50.0 degrees to 35.0 degrees from the vertical. Also notice that the last two numbers are now both set to 1. This means that the player's entire party will track the militiaman's movement, with both the players and their cameras turning to face the soldier. We have also set the iParty option in the start and stop cutscene functions to match.
#include "in_g_cutscene"
void main()
{
object oPC = GetFirstPC();
object oWPStart = GetWaypointByTag("wp_start");
object oWPEnd = GetWaypointByTag("wp_end");
object oMilitia = GetObjectByTag("militia");
GestaltStartCutscene(oPC, "trackcam");
GestaltActionJump (0.0, oMilitia, oWPStart);
GestaltActionMove (0.5, oMilitia, oWPEnd);
GestaltCameraTrack (0.5,
oMilitia,
0.0, 0.0,
0.0, 0.0,
10.0, 4.0,
oPC, 2));
GestaltStopCutscene (11.0, oPC);
}
One last script, again tracking the militiaman. This time though iFace is set to 2, meaning that only the player will turn to track the target. Because the camera remains stationary throughout we don't need to worry about the range and tilt settings, although the numbers must still be included - I've set them all to 0.0. Also notice that I've set the frame rate much lower than normal. This is because the player shuffles round by several degrees at a time when he turns, so as we're not moving the camera we don't need to worry about how smooth the motion is - it won't make any difference in this case. For obvious reasons we are stopping the player from moving their character around manually during this movement. You might want to add a few more waypoints and GestaltActionMove commands for this script to see what happens when the guard runs around the player in a circle. |