29.09.2016, 04:54
You could rewrite your code to something like below:
Just remember to kill the timer when you're done with it.
Also, note that interpolate functions aren't fully accurate in terms of working. They do not always move your camera. You could replace its usage for SetPlayerCameraLookAt, using CAMERA_MOVE in the cut parameter, but you'd be sacrificing the control over time.
pawn Код:
// Initialize
TogglePlayerSpectating(playerid, true);
CameraMovement[playerid] = 0;
KillTimer(ConnectionCamera[playerid]);
ConnectionCamera[playerid] = SetTimerEx("ConnectionCameraMovement", 1000, true, "i", playerid);
// Function
forward ConnectionCameraMovement(playerid);
public ConnectionCameraMovement(playerid)
{
switch(CameraMovement[playerid])
{
case 0:
{
InterpolateCameraPos(playerid, 1977.940917, -1753.394165, 15.710048, 1683.647583, -1725.149780, 15.520676, 13000);
InterpolateCameraLookAt(playerid, 1972.946899, -1753.489624, 15.485646, 1688.493530, -1726.381225, 15.500365, 2000);
CameraMovement[playerid] ++;
}
case 1:
{
InterpolateCameraPos(playerid, 905.286132, -1403.625976, 15.154844, 1353.317626, -1404.655395, 15.989136, 10000);
InterpolateCameraLookAt(playerid, 910.276306, -1403.326171, 15.062310, 1349.223632, -1401.786621, 15.892268, 2000);
CameraMovement[playerid] ++;
}
case 2:
{
InterpolateCameraPos(playerid, 1584.561767, -1731.501708, 14.498149, 1334.697753, -1722.911621, 15.104587, 10000);
InterpolateCameraLookAt(playerid, 1579.567993, -1731.750732, 14.477837, 1338.359619, -1726.315917, 15.058754, 2000);
CameraMovement[playerid] ++;
}
case 3:
{
InterpolateCameraPos(playerid, 165.131668, -1885.581787, 1.454522, 636.477600, -1918.955688, 5.688834, 10000);
InterpolateCameraLookAt(playerid, 170.110122, -1885.167968, 1.663836, 631.661071, -1917.679565, 5.273429, 2000);
CameraMovement[playerid] ++;
}
default:
{
InterpolateCameraPos(playerid, 1828.909790, -1602.995971, 13.485791, 1857.642089, -1431.320312, 16.744033, 10000);
InterpolateCameraLookAt(playerid, 1825.495117, -1599.407348, 14.165193, 1852.764038, -1432.402221, 16.557880, 2000);
CameraMovement[playerid] = 0;
}
}
return 1;
}
Also, note that interpolate functions aren't fully accurate in terms of working. They do not always move your camera. You could replace its usage for SetPlayerCameraLookAt, using CAMERA_MOVE in the cut parameter, but you'd be sacrificing the control over time.